Solved Command Batch: Running a For / R loop on multiple file types

August 10, 2012 at 01:18:16
Specs: Windows 7
Hi,

I would like to be able to run a Windows command batch on multiple file types, for instance JPG and GIF.

for /R "%originalpath%" %%G in (*.jpg) DO (

Currently I'm stuck with either one file type (JPG in the example above) or all ( in (*.*) )
Is there a way I can specify a list of file types?

Thanks!

Blaise


See More: Command Batch: Running a For / R loop on multiple file types

Report •

#1
August 10, 2012 at 01:50:59
✔ Best Answer
:: ===== script starts here ===============
::
:: blaise.bat 2012-08-10 15:45:47.12
@echo off & setLocal enableDELAYedeXpansioN

pushd c:\

for /f "tokens=* delims= " %%a in ('dir/b/s *.jpg *.gif') do (
echo %%a
)
::====== script ends here =================


====================================
Life is too important to be taken seriously.

M2


Report •

#2
August 10, 2012 at 02:36:26
Mechanix2Go - Thank you. This is so elegant and minimalist that it touches art.

Never saw or heard about the PUSHD command before.

Well done,

Blaise


Report •

#3
August 10, 2012 at 03:43:21
Blaise,

Thanks for the encouragement.

M2 & N2


====================================
Life is too important to be taken seriously.

M2


Report •
Related Solutions


Ask Question