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.
Search with batch file
Name: amlife Date: October 27, 2008 at 06:13:21 Pacific OS: XP CPU/Ram: 2GB Product: HP
Comment:
Hello
I was wondering it it is possible to creat batch file will search %systemdrive% for files and backup them up to backup folder.
example.
search for *.jpg and copy to backup\jpg search for *.doc and copy to backup\MS word search for *.ppt and copy to backup\MS power point
I tired to use IF FOUND statement. but it will look into single directory not sure if there is any special switch will make it look into subdirectories
Name: Mechanix2Go Date: October 27, 2008 at 07:10:47 Pacific
Reply:
@echo off setLocal EnableDelayedExpansion
for %%a in (jpg doc ppt) do ( for /f "tokens=* delims= " %%f in ('dir/b/s/a-d %systemdrive%\*.%%a') do ( echo copy "%%f" d:\bakup\%%a ) )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: amlife Date: October 27, 2008 at 07:21:35 Pacific
Reply:
Thanks Mechanix2Go
I just want to know now, will this search the entire hard drive ? including all subfolders?
how can I add more extensions ex. *.GIF *.XLS
Thank you
0
Response Number 3
Name: Mechanix2Go Date: October 27, 2008 at 07:27:12 Pacific
Reply:
Yes, it'll do the whole drive.
Put additional exts in here:
(jpg doc ppt)
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 4
Name: amlife Date: October 27, 2008 at 07:33:39 Pacific
Reply:
sounds good, thanks for your help, will create that bat file and will post feedback soon :-)
0
Response Number 5
Name: amlife Date: October 27, 2008 at 08:27:28 Pacific
Reply:
ok .. I'm not sure what is wrong, but it not copying anything .. I can't see anything in the "bakup" folder. however I was able to see listing for all extensions provided, I didn't see any errors..
0
Response Number 6
Name: Mechanix2Go Date: October 27, 2008 at 08:33:18 Pacific
Reply:
Sorry as written, it previews what's to be done.
To activate, edit out the ECHO before COPY.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 7
Name: amlife Date: October 27, 2008 at 09:39:28 Pacific
Reply:
removed the echo, and it is working as it should be .. thanks again for your assistance.
Summary: Hi, I was wondering if it is possible to get the last line of a text file and save it to a variable? I found a script that gets the first line, but I have been unable to write one of my own. I could...
Summary: I want to do a (preferably) batch file, that searches for a certain string in a file and deletes the line its at. So if for example the file consists of: multi square john 3323 single square johnp 351...
Summary: If a batch file doesn't do it, any halfway decent text processor with search and replace should be able to do all but the first and last lines which you can fix manually. ...