Using .BAT files and COPY commands - problems

  • Thread starter Thread starter brad
  • Start date Start date
B

brad

I want to write a quick .bat file and run it from my
desktop......In my .bat file, I want to copy all files AND
sub-directories and their files to a mapped network
drive......the copy c:\data\*.* z: (where Z is the mapped
drive) does not work all the way....it copies only files,
but not sub-dirs....any ideas...thanks

brad
 
brad said:
I want to write a quick .bat file and run it from my
desktop......In my .bat file, I want to copy all files AND
sub-directories and their files to a mapped network
drive......the copy c:\data\*.* z: (where Z is the mapped
drive) does not work all the way....it copies only files,
but not sub-dirs....any ideas...thanks

Use XCOPY with the S switch

xcopy c:\data z:\whatever /s /e /i

optionaly ad /c to continue on errors and /Y to not prompt you about
overwriting existing files.

At tyhe command prompt type xcopy /? to see all the xcopy options
 
thanks, one more quick question....i'm having trouble with
a similar thing, except the error msg is saying that it
can't find the file....One of the files that I'm also
trying to copy is my outlook.pst file...when I go through
the Dos command prompt, I can get to the file just fine,
however when I write the copy command out, with all the
directories, etc. listed, it says it can't find the
file....any ideas?

thanks for your help.
brad
 
brad said:
thanks, one more quick question....i'm having trouble with
a similar thing, except the error msg is saying that it
can't find the file....One of the files that I'm also
trying to copy is my outlook.pst file...when I go through
the Dos command prompt, I can get to the file just fine,
however when I write the copy command out, with all the
directories, etc. listed, it says it can't find the
file....any ideas?

thanks for your help.
brad

1) Make sure any files with a space in the name are enclosed in quotes, i.e.
"Personal Folders.PST"
2) Make sure the PST file is not in use.

--

Mike Brown
Asset Forwarding Corp.
EPA-compliant Recycling
DoD 5220.22-M Data Elimination
http://www.assetforwarding.com
 
The file I'm trying to copy is the standard outlook.pst
file.....I have not changed anything with respect to the
name of the file....the file is located here:

C:\Documents and Settings\Brad\Local Settings\Application
Data\Microsoft\Outlook\outlook.pst

When I type the copy command in a .bat file, it says it
can't find the file.....

thanks
brad
 
Follow Mike's suggestion...

The whole path (not just the filename) must be in quotes, if there are
spaces any way along it.
The DOS 'CD' command to change directory, will work without quotes (for some
unknown reason) so you will be able to manually CD into the correct place.
However, 'COPY' does not work without quotes, when copying paths containing
spaces.

Make your copy command something like...

copy "C:\Documents and Settings\Brad\Local Settings\Application
Data\Microsoft\Outlook\outlook.pst" wherever

where 'wherever' is replaced by the path you want the file copied to. Again,
if there's spaces in it, remember to put quotes round the whole path...

Hope this helps,

Jeff
 
Just for th ehell of it. How to backup Outlook on XP Pro for the current
user.
if one changes the taskkill line to something like pskill or a WMI/VBS
script to kill Outlook, it'll work with other NT+ OS'es.

I keep Outlook running 24x7 except for the daily backup which is why it's
restarted after the backup. :)

@echo off
:: BackupOutlookMailXP.cmd
setlocal ENABLEEXTENSIONS

:: Backups go here
set envBackupLoc=\\Bliss\C$\Outlook Backup

:: Default location of email
set envMail=%USERPROFILE%\Local settings\Application data\Microsoft\Outlook

:: Use the Quick Launch shortcut to restart Outlook
set envQL=%USERPROFILE%\Application Data\Microsoft\Internet Explorer\Quick
Launch\launch microsoft outlook.lnk

:: Kill running instances of Outlook
%WINDIR%\System32\taskkill.exe /F /IM OUTLOOK.EXE

:: Do the backup
xcopy "%envMail%" "%envBackupLoc%" /c /e /i /s /y

:: Restart Outlook
"%envQL%"

endlocal
 
The DOS 'CD' command to change directory, will work without quotes (for some
unknown reason)

Since CD can only accept a maximum of *one* argument, there's no reason
to treat an unprotected space as an argument separator in this context.
 
-----Original Message-----
I want to write a quick .bat file and run it from my
desktop......In my .bat file, I want to copy all files AND
sub-directories and their files to a mapped network
drive......the copy c:\data\*.* z: (where Z is the mapped
drive) does not work all the way....it copies only files,
but not sub-dirs....any ideas...thanks

brad
.
Brad,

You need to use the Xcopy command with the /s parameter.
The /s will copy all sub-dirs. You can also add the /e
to copy empty directories as well. Hope that helps.

Dave
 
Back
Top