command prompt - Invalidate match in batch file for loop -


i have following directory structure:

>c     >somefile         >.ignoreme             >vitalsysteminfo.eiafj             >donttouchthis.ei3rw3j         >picture.jpg         >pandas.gif         >code.cpp         >anotherdirectory             >morestuff.bacon 

and have loop go through it

for /r %f in (c:\somefile) echo %f 

how can exclude .ignoreme?

you appear little confused syntax of for /r. should be

for /r "folder" %f in (filemask) echo %f 

you should double-pump percent signs if you're putting in .bat script.


anyway, if you're doing echoing results, easiest way exclude ".ignoreme" pipe output find /v ".ignoreme".

for /r "c:\somefile" %%f in (*) echo %%f | find /v /i ".ignoreme" 

on other hand, if use of echo merely demonstration not production, can accomplish same effect for /f loop executing dir /s /b.

for /f "delims=" %%f in ('dir /s /b "c:\somefile" ^| find /v /i ".ignoreme"') echo %%f 

if want fancy, take advantage of fact for /d excludes hidden folders.

attrib +h "c:\somefile\.ignoreme" >nul 2>nul /d /r "c:\somefile" %%i in (*) (     %%j in ("%%~i\*") echo "%%~fj" ) 

even though that's more code, more efficient (faster) excluding find /v. you'll find internal cmd functions execute more executables such find.exe.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -