how to improve Search And Copy File With Bat

November 27, 2010 at 10:42:41
Specs: Windows XP
I am looking for a batch file that will search the entire pc for jpg files and copy them on a usb stick. The batch programm should be on the usb and copy all jpg files of the pc (without the jpg files in the Temporary Internet Files) on the usb-stick where the batch file is.

there are the batch file , but how canI copy all the jpg files but wihtout those in the Temporary Internet Files? sorry for my bad English.

for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\ (
for /f "tokens=* delims= " %%d in ('dir/b/s/a-d %%a:\*.jpg 2^> nul') do (
copy "%%d"
)
)
)


See More: how to improve Search And Copy File With Bat

Report •

#1
November 27, 2010 at 11:06:18
SETLOCAL EnableDelayedExpansion

for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\ (
for /f "tokens=* delims= " %%A in ('dir/b/s/a-d %%a:\*.jpg 2^> nul') do (
ECHO %%~dpA | FIND "Temporary Internet Files"
IF NOT "%ErrorLevel%"=="0" COPY "%%A" "New Location"
)
)
)

Can I put a question here?


Report •

#2
November 27, 2010 at 11:18:04
of course you can ask

the batch is useful but it still search for the jpg file in that file
that waste a lot of time..

by the way, i want to search the "my documents" file first..


Report •

#3
November 27, 2010 at 13:16:55
... I was assuming the code you supplied did what you wanted it to do. If that's not the case you should have said so (not including the temp file issue).

Do you want to search your entire hard drive or just the my documents folder? I'm not psychic.

Can I put a question here?


Report •

Related Solutions

#4
November 27, 2010 at 15:51:33
I want to search the document folder and copy it to the usb stick first, after that search the entire hard drive (not including the temp file issue), then copy it to the usb stick

Thank you for everyone !!


Report •

#5
November 27, 2010 at 16:41:09
If you are going to do the rest of the hard drive anyways, why bother with doing the documents folder first? Because of space?

@ECHO OFF&SETLOCAL EnableDelayedExpansion

COPY "Path:\To\MyDocuments\*.jpg" "Path:\To\USBDrive\*.jpg"

FOR /f "tokens=* delims= " %%a IN ('dir /b /s /a-d "*.jpg"') DO (
SET Var=0
ECHO %%~dpA | FIND "Temporary Internet Files">Nul
IF NOT "%ErrorLevel%"=="0" SET Var+=1
ECHO %%~dpA | FIND "My Documents">Nul
IF NOT "%ErrorLevel%"=="0" SET Var+=1
IF "%Var%"=="2" COPY "%%~dpA\%%a.jpg" "Path:\To\USBDrive\%%a
)

Can I put a question here?


Report •

#6
November 28, 2010 at 01:15:01
yes because of space..
I cant load the batch file .. have bug?

Report •

#7
November 28, 2010 at 07:32:41
by the Way "Can I put a question here?" is Matt's Signature word.

Matt I m (Many others will as well) wondering what does this mean. Of-course If u don't mind sharing the meaning.

Subhash Chandra.


Report •

#8
November 28, 2010 at 10:16:53
fromhk,

What are the error details?

----
subhashchy,

It was my attempt at a joke. When you go to add a signature on your profile, it says "Do not put a question here." So, I went a head and put that. I guess that's just my sense of humor.

Can I put a question here?


Report •

#9
November 29, 2010 at 02:50:52
Make sense ..Thank you.
I m still in learning phase and getting much info from your codes...
Thank you sharing your knowledge,

Subhash Chandra.


Report •

Ask Question