Search and Move

March 25, 2010 at 09:04:05
Specs: Windows XP
Hi all... I'm trying to write a batch file that will search c&d drives for *.pst file(s) and move (or copy & delete) them to a destination folder on the d: drive. I think I have it defeated except when I go to my d: drive the entire folder and subfolders have been copied instead of just the actual file. Can you help?

See More: Search and Move

Report •


#1
March 25, 2010 at 15:24:26
Can you post your script ?

Report •

#2
March 25, 2010 at 19:08:33
install findutils and coreutils
from GNU. then

c:\> gnu_find.exe c:\* d:\* -type f -iname "*.pst" -exec mv {} e:\destination ;

GNU win32 packages | Gawk


Report •

#3
March 26, 2010 at 01:43:53
LOL difficult to debug a bat without seeing it.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
March 26, 2010 at 04:29:51
second that

Report •

#5
March 26, 2010 at 06:01:28
Sorry guys... Here it is... In response to findutils and coreutils that's not an option because I have to run this on over 400 machines and can't intall that on all of them. I know the /s the reason it is copying the directory structure but without it the script doesn't search the entire drive...

xcopy C:\*.brg d:\pst\%username% /s
del c:\*.pst /s
pause


Report •

#6
March 26, 2010 at 06:29:38
to make it clear, downloading coreutils+find is just one time only. you can just save mv.exe, find.exe and your batch script (ie .bat file) to your disk/floppy and bring it to your PCs to run it.
You are definitely not going to every PC, open up the browser and download them again and again.

GNU win32 packages | Gawk


Report •

#7
March 26, 2010 at 06:34:08
So I can just save mv.exe and find.exe and my bat file to a flash drive and go from there... sounds good. Where do i get the exe files? Sorry so many questions.

Report •

#8
March 26, 2010 at 06:51:55
yes, you can save mv.exe and find.exe to your thumbdrive.
see my previous reply. i gave you the links for download.

GNU win32 packages | Gawk


Report •

#9
March 26, 2010 at 07:09:21
Awesome... Working great. Thanks

Report •

#10
March 26, 2010 at 23:45:04
"the entire folder and subfolders have been copied instead of just the actual file"

Not obnious how, but I'll go along with the joke.


=====================================
Helping others achieve escape felicity

M2


Report •

#11
March 27, 2010 at 03:30:03
I dont see how the code in response 5 relates to the initial question. But, I do know this : if you look on one drive, for a type of files, and you copy them to a certain directory on the SAME drive, you will hit issues since the source files and the target files will get mixed up.

In other words, when you do the search on the D drive, you will need to exclude the directory to which you copy to. I know that advanced copy tools (like Robocopy and XXCOPY) have such features, and XCOPY does not.


Report •

#12
March 27, 2010 at 03:32:41
> to make it clear, downloading coreutils+find is just one
> time only. you can just save mv.exe, find.exe and your
> batch script (ie .bat file) to your disk/floppy and bring it
> to your PCs
> to run it.
> You are definitely not going to every PC, open up the
> browser and download them again and again.
>

This is indeed a trick that I often use as well, I install this kind of stuff, but I only take the commands out of them, which I need. Mostly they work, some may need 1 DLL or so, but almost never you have to repeat installations. Just copy the wanted EXEs to where you need them.


Report •

#13
March 27, 2010 at 05:39:08
This thing is so far out to lunch it's almost back from lunch. [If you believe in curved space-time.]

You don't need 3rd party utils.

------------------------------------
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/a-d c:\*.bak d:\*.bak') do (
move /y "%%a" d:\mystuff\
)


=====================================
Helping others achieve escape felicity

M2


Report •

#14
March 27, 2010 at 06:42:59
maybe not for just moving files. but having such tools with extra features around is sure handy. eg moving files that are 30days old...with just batch, you need to do the calculation yourself...

GNU win32 packages | Gawk


Report •

#15
March 27, 2010 at 08:45:49
> You don't need 3rd party utils.
>

In this thread, or in general ?


Report •


Ask Question