We help IT Professionals succeed at work.

Copy all Jpeg files to a single folder

GSLElectric asked
I'm wanting to make a copy of all jpg filesfrom a given hard drive and copy them to a folder on the same server.  I will then back those files up to an external device.  Does someone know the syntax that would allow me to perform this task?
Watch Question

Search for *.jpg at the server, in the results screen, mark all the files, cut the files and paste them in the directory of your choice.
You could do this with the xcopy command, e.g.
xcopy c:\*.jpg "d:\destination folder\" /s /c /h /r /y

For greater reliability you could also use Robocopy, e.g.
robocopy c:\ "d:\destination folder" /s *.jpg

No easy way of doing this.
from c:\  do
"c:\> dir *.jpg /s"

this will give you all the paths.
see "xcopy /?" for more info
Steven CarnahanAssistant Vice President\Network Manager

You could try this
@Echo Off
SetLocal EnableDelayedExpansion
::This line is just in case n has been defined before the batch file is run
Set n=
cd "c:\"Documents and Settings"
mkdir c:\pics
dir /b /s *.jpg > c:\pics\listing.txt
Set _InputFile=c:\pics\listing.txt
For /F "tokens=*" %%I IN (%_InputFile%) DO (
cd c:\pics
:: comment out the following if you don't want to watch the progress
echo Now copying: "%%I"
xcopy "%%I"
Set /a n+=1
Set _var!n!=%%I

Open in new window

Steven CarnahanAssistant Vice President\Network Manager

Line 5 is where you want to start the search from.  You may want to change it to c:\ as I was using Documents and Settings to limit my search.