Batch Files: recursively check for file attributes -


i've looked @ topic: testing file attribute in batch file

the script works specified folder in %input%, if want subfolders, doesn't work. when add suggested /r flag, nothing @ happens. syntax correct?

for /r %%f in (%input%) ( ... ) 

thanks scott

you need specify base directory after /r. whatever specified in parentheses appended each subdirectory in tree. can use . directory itself:

for /r %input% %%f in (.) ( ... ) 

also, 1 weird thing discovered if use enabledelayedexpansion syntax, doesn't work; executes body base directory, not subdirectory. following not work, whether have enabledelayedexpansion enabled or not:

for /r !input! %%f in (.) ( ... ) 

another quirk of dosbatch.

edit: address comment, becomes relevant ... contains. should work if want attributes on both current iteration directory , files contained within current iteration directory:

for /r %input% %%f in (.) (attrib %%f& attrib %%f\*) 

edit: here's potential solution, slower, on other hand might make code easier write. on other hand, have problems whitespace in file names:

for /f %%i in ('dir /b /s %input%') (attrib %%i) 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -