开发者

Please help me with my Batch Script

开发者 https://www.devze.com 2023-04-03 03:39 出处:网络
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 a

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 thro开发者_运维问答ugh 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.


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


Have you tried the following yet?

dir /s /b "C:\Documents and Settings\Robert\Desktop\BHI_P\frame\*.xml"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号