issues with batch find and file backup to mapped drive

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Raistlin73
Posts: 4
Joined: 23 Jan 2012 03:55

issues with batch find and file backup to mapped drive

#1 Post by Raistlin73 » 23 Jan 2012 04:03

I have a script that will find all pst files on a drive and backup to a network folder. The 2 issues i have come across is
1. duplicate file names
2. running the scriped from a mapped drive. When running the script from a mapped drive IE. p: it will only search that drive not the local drive c:
Here is the code i have.

:input
@Echo Please enter the SSO # to backup PST Files
@set EU=
@set /P EU=Type input: %=%
@if "%EU%"=="" goto input

:: pst copy
cd c:\
dir /s /b *.pst >c:\pst.txt
setlocal enabledelayedexpansion
for /f "delims=" %%a in (c:\pst.txt) do (xcopy "%%a" "\\network drive\geo\%EU%\" /E /I /Q /Y)
del /q c:\pst.txt
endlocal

Any help would be greatly appreciated.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: issues with batch find and file backup to mapped drive

#2 Post by Squashman » 23 Jan 2012 06:48

When changing the DRIVE and path you have to use the /D switch with the CD command.

I usually prefer to just use the PUSHD command instead.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: issues with batch find and file backup to mapped drive

#3 Post by Squashman » 23 Jan 2012 06:56

Why didn't you use a FOR /R like you posted in this thread.
viewtopic.php?f=3&t=2763&p=13020#p13020

Or you could put the DIR command into the FOR loop instead of writing the output to a text file.

Code: Select all

cd /d C:\
for /f "delims=" %%a in ('dir /a-d /s /b *.pst') do (xcopy "%%a" "\\network drive\geo\%EU%\" /E /I /Q /Y)
Last edited by Squashman on 23 Jan 2012 08:47, edited 1 time in total.

Raistlin73
Posts: 4
Joined: 23 Jan 2012 03:55

Re: issues with batch find and file backup to mapped drive

#4 Post by Raistlin73 » 23 Jan 2012 08:19

Thank you Squashman. A fresh set of eyes done the trick. i don't know why i didn't think of that. adding the /D done the trick thank you :)

Raistlin73
Posts: 4
Joined: 23 Jan 2012 03:55

Re: issues with batch find and file backup to mapped drive

#5 Post by Raistlin73 » 24 Jan 2012 00:16

Now the only issue i have is the duplicate names when it saves to the network folder. Anyone have any idea's?

Post Reply