@echo off setlocal EnableDelayedExpansion set unwantedFiles=foo bar baz for %%g in (*.sql) do ( set "test=!unwantedFiles:%%~Ng=!" if "!test!" == "!unwantedFiles!" ( echo %%~Ng.sql is not unwanted, process it: echo Process with %%g ) )
Take a name and copy unnecessary files by deleting the current name. If the result is the same as before, this name is NOT in the unwanted files, so process it ...
source share