The code is like this but it doesn't work as expected right now:
@ECHO OFF
for /f %%i in ('dir *.mov /b') do call :test %%i
goto continue
:test
if "%1"=="*compressed.mov" goto :eof
echo "%~f1"
goto :eof
:continue
pause
I would like to solve two problems here:
How to escape spaces in file names? ie. I would like to include "video 1.mov" file for the test and not echo just the "Drive:\path\video" but instead "Drive:\path\video 1.mov"
How to not echo any file containing string "compressed" at the end of it's name?
CodePudding user response:
Perhaps something like this would suit:
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
For %%G In ("*.mov") Do If /I "%%~xG" == ".mov" (Set "_=%%~nG"
SetLocal EnableDelayedExpansion
If /I Not "!_:~-10!" == "compressed" (EndLocal & Echo "%%~fG"
) Else EndLocal
)
Pause
Alternatively use findstr.exe
:
@For /F "EOL=? Delims=" %%G In ('Dir "*.mov" /A:-D /B 2^>NUL ^| %SystemRoot%\System32\findstr.exe /LIE ".mov" ^| %SystemRoot%\System32\findstr.exe /VLIE "compressed.mov"') Do @Echo "%__CD__%%%G"
@Pause