Computing.Net > Forums > Windows XP > Batch: goto to every subfolder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch: goto to every subfolder

Reply to Message Icon

Name: CeeJay
Date: November 14, 2007 at 08:33:56 Pacific
OS: XP SP2
CPU/Ram: ?
Product: ?
Comment:

Hi there,
is there a possibility to say a batchfile, to go in every subfolder (from current folder) and run a command.
for example:
myfolder:
- folder1
- folder2
- fodler3

he should go in folder1 create a textfile!
than goto to folder2 and do the same textfile,
and in the end to folder3 and again the textfile...

the batchfile have to be variable, so the subfolders can change an he should do it all by its own?

would be great if you can tell me how to solve

mfg CJ



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: November 14, 2007 at 10:19:12 Pacific
Reply:

Yes:

for /r %d in (.) do copy textfile %d

By the way, you should have asked this sort of question in the programming forum.


0

Response Number 2
Name: CeeJay
Date: November 15, 2007 at 06:31:04 Pacific
Reply:

thanx for help, this is what i was searching for, one little problem left:

for /r %d in (.) do @if exist %d\*.txt echo %d

this what i got, just for testing now. when i copy it in the cmd it runs perfectly but when i copy it into a batchfile an run this it got error!!!

can you tell me why?


0

Response Number 3
Name: Mechanix2Go
Date: November 15, 2007 at 07:23:43 Pacific
Reply:

A BAT strips one %; so you need:

for /r %%d in (.) do @if exist %%d\*.txt echo %%d



=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


System Restore not availa... Boot Problem



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch: goto to every subfolder

Batch file to read an ini & more... www.computing.net/answers/windows-xp/batch-file-to-read-an-ini-amp-more/95707.html

Batch file to backup Favourites www.computing.net/answers/windows-xp/batch-file-to-backup-favourites/46469.html

how to share subfolders on lan? www.computing.net/answers/windows-xp/how-to-share-subfolders-on-lan/135669.html