Reputation: 6831
I wrote a very simple batch script to list all the xml files under "frame" folder.
Basically, I have a "frame" folder it contains seven sub-folders, under each of these seven sub-folders, there are some xml files. But there are no direct xml files under "frame" itself.
So my batch script is intended to loop through frame folder "recursively" to list out all the ".xml" files.
My script looks like:
FOR /r %%c in ("C:\Documents and Settings\Robert\Desktop\BHI_P\frame\"*.xml*) DO echo %%c
It won't work, but if I took out the /r and appended the subfolder after "frame\", it will list the xml file under that particular sub folder.
Could any body help me and give me some explanation? Thanks.
Upvotes: 0
Views: 179
Reputation: 61269
How about
For /R "C:\Documents and Settings\Robert\Desktop\BHI_P\frameframe\" %%i in (*.xml) DO echo %%i
Testing
C:\tmp\so>mkdir robert
C:\tmp\so>cd robert
C:\tmp\so\robert>mkdir frame\a\b\c\d\e\f
C:\tmp\so\robert>mkdir frame\a\b\c\d\e\f1
C:\tmp\so\robert>mkdir frame\a\b\c\d\e\f2
C:\tmp\so\robert>mkdir frame\a\b\c\d\e\ff3
C:\tmp\so\robert>echo > frame\a\a.xml
C:\tmp\so\robert>echo > frame\a\a1.xml
C:\tmp\so\robert>echo > frame\a\b\b.xml
C:\tmp\so\robert>echo > frame\a\b\c\c.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\d.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\e\e.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\e\f\f.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\e\f1\f1.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\e\f2\f2.xml
C:\tmp\so\robert>echo > frame\a\b\c\d\e\ff3\ff3.xml
Output
C:\tmp\so\robert>robert.bat
C:\tmp\so\Robert\frame\a\a.xml
C:\tmp\so\Robert\frame\a\a1.xml
C:\tmp\so\Robert\frame\a\b\b.xml
C:\tmp\so\Robert\frame\a\b\c\c.xml
C:\tmp\so\Robert\frame\a\b\c\d\d.xml
C:\tmp\so\Robert\frame\a\b\c\d\e\e.xml
C:\tmp\so\Robert\frame\a\b\c\d\e\f\f.xml
C:\tmp\so\Robert\frame\a\b\c\d\e\f1\f1.xml
C:\tmp\so\Robert\frame\a\b\c\d\e\f2\f2.xml
C:\tmp\so\Robert\frame\a\b\c\d\e\ff3\ff3.xml
Upvotes: 2
Reputation: 40803
Have you tried the following yet?
dir /s /b "C:\Documents and Settings\Robert\Desktop\BHI_P\frame\*.xml"
Upvotes: 1