I am trying to do essentially the same as in this question, i.e. I want to loop through files in a directory, but exclude files that have in their name a certain string (in my case ".new.". However, the problem is that I am using
setlocal DisableDelayedExpansion
because I want the batch also to work with file names that contain exclamation marks. I have thus tried to make the solution work using directly the loop variable %%x instead of a new variable, but that does not appear to work:
setlocal DisableDelayedExpansion
For %%x in (*.mkv *.mp4) do (
If "%%x" == "%%x:.new." (
Echo Skipped "%%x"
) Else (
Echo Processing "%%x"
)
)
String matching doesn't work, i.e. I get
Processing "file.mkv"
Processing "file.new.mkv"
Any hint for how I could get this to work would be greatly appreciated; thanks!