For loop file name to see if it contains any of the possible? -
somehow can use loop (/r) see if file name contains 1 of 3 or more different parts?
for /r "c:\" %%a in ("*.*") ( if %%~nxa==a*.txt echo if %%~nxa==*b.txt echo b )
etc.?
is possible?
either of following should give logic have specified:
for /r "c:\" %%f in ("a*.txt" "*b.txt") echo %%f
or
dir /s /b /a-d "c:\a*.txt" "c:\*b.txt"
but, must realize duplicate listings because file "a_b.txt" match both masks - each mask listed separately.
you use following distinct values:
@echo off setlocal disabledelayedexpansion set "prior=" /f "delims=" %%f in ( 'dir /s /b /a-d "c:\a*.txt" "c:\*b.txt" ^| sort' ) ( set "now=%%f" setlocal enabledelayedexpansion if !now! neq !prior! echo !now! endlocal set "prior=%%f" )
or use jsort.bat utility conveniently , efficiently sort , remove duplicates. jsort.bat pure script (jscript/batch hybrid) runs natively on windows machine xp onward.
dir /s /b /a-d "c:\a*.txt" "c:\*b.txt" | jsort /u
Comments
Post a Comment