|
-
Mar 16th, 2011, 07:51 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] For Loop file filter in a .bat or .cmd file
Hi,
I'm not sure if this is the best place to post this question so please forgive me if it's not.
I've got a for loop in a batch file that loops ".jpg" files and I'd like to change it to find ".jpg" and ".pdf" files.
Is this possible?
Code:
SET counter=0
FOR /r "e:\test\myfiles\" %%X IN (*.jpg) DO (set /a counter+=1)
ECHO Copied %counter% of 5 file(s)
Any help or ideas will be greatly appreciated.
Regards Al
-
Mar 16th, 2011, 11:38 AM
#2
Re: For Loop file filter in a .bat or .cmd file
Presuming what you have works, why not just add another FOR with a another counter variable
Code:
SET counter=0
SET pdfCounter = 0
FOR /r "e:\test\myfiles\" %%X IN (*.jpg) DO (set /a counter+=1)
FOR /r "e:\test\myfiles\" %%X IN (*.pdf) DO (set /a pdfcounter+=1)
ECHO Copied %counter% of 5 file(s)
ECHO Copied %pdfcounter% of 5 file(s)
-
Mar 16th, 2011, 11:40 AM
#3
Thread Starter
Fanatic Member
Re: For Loop file filter in a .bat or .cmd file
As a workaround I've applied the following which works but I was hoping for a cleaner solution.
Code:
SET counter=0
FOR /r "e:\test\myfiles\" %%X IN (*.jpg) DO (set /a counter+=1)
FOR /r "e:\test\myfiles\" %%X IN (*.pdf) DO (set /a counter+=1)
ECHO Copied %counter% file(s)
-
Mar 16th, 2011, 11:43 AM
#4
Thread Starter
Fanatic Member
Re: For Loop file filter in a .bat or .cmd file
Hack,
Snap you suggested pretty much what I've managed to figure out. I must have started typing out my reply just before you posted yours.
Many thanks
Cheers Al
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|