Invert the meaning of the FOR command?
With batch files, it is easy enough to handle all files that share a string in a filename or extension, for example:
FOR /R %F IN (*.EXE) DO @ECHO %F
But what if I want to invert the meaning of a set of files? For example, handle all files that don't end with .EXE?
FOR /R %F IN (anything-but-exe) DO @ECHO %F
I could not find anything similar to what I was looking for by reading the output FOR /?
+3
Govind Parmar
source
to share
2 answers
for /f "tokens=* delims=" %a in ('dir /s /b /a:-d^|findstr /i/e/v ".exe" ') do @echo %a
+5
npocmaka
source
to share
This should be another option:
FOR /R %F IN (*.*) DO @if /i not "%~xF"==".exe" ECHO %F
+4
foxidrive
source
to share