Hi,
I was trying to write a for loop to recursively go over all the files in a specified directory:
FOR /R %1 %%i in (*) do call batch.bat %%i
My only problem is that it ignores hidden files.
Any clues on how to include hidden files?
Thanks
~Steve
**Edit
After some searching I found a way to display the names:
DIR /A/OGN
That doesn’t exactly help me though as the batch I call in the for loop doesn’t see the file when I pass it the name on its own.
It’s an interesting question … I think you have to use /F instead of /R, basically to allow a command to be used. The problem with the “set” is that it is meant for standard behaviour, which is not what you want. I came to this :
for /F %%f in (‘dir *.* /B /S /AH’) do echo %%f
It does look for files in subdirs, and it does show the hidden ones … but the problem is then this : it only shows the hidden ones. So, you would have to run this as well (for the non-hidden files) :
for /F %%f in (‘dir *.* /B /S /A-H’) do echo %%f
which should be the same as:
for /F %%f in (‘dir *.* /B /S’) do echo %%f
It also shows the full path, so no issue with file not being found cause you run it from different path or so.
@echo off & setLocal EnableDELAYedeXpansion
for /f “tokens=* delims= ” %%a in (‘attrib /s d:\*.*’) do (
set F=%%a
set F=!F:~11!
echo !F!
)