Find Files, Promt User for Move Location

July 14, 2009 at 22:09:58
Specs: Windows XP
I would like a batch files to perform the following:

Find all .PST files on C and D drives
Then prompt the user for a directory name
Copy all files found to the directory entered
Confirm with user for file overwrites

This sounded so simple when I first looked at it, I know how to search for files etc. - dir /S c:\*.pst. But then it got way above my head.

Please can someone offer some help on this
Thanks

Simon


See More: Find Files, Promt User for Move Location

Report •


#1
July 14, 2009 at 23:49:24
@echo off & setLocal EnableDELAYedExpansion

set /p dest=destination directory ? :

for /f "tokens=* delims=" %%a in ('dir/b/s/a-d c:\*.PST d:\*.PST 2^>nul') do (
echo %%a
copy /-y "%%a" !dest!\
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
July 16, 2009 at 01:34:28
Mechanix2Go
Thanks you so much, this worked great.

I need to look up these switches you have used to see what they are actually doing. But you may be able to help me understand the the 'for' and 'do' statement. Are all files found before the 'do' is executed? Or is the 'do' executed upon finding each iteration in the 'for'?

This is just my curiosity and the desire to understand more.

Simon


Report •

#3
July 16, 2009 at 02:37:59
the 'do' executed upon finding each iteration in the 'for'


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions


Ask Question