Dos Batch exclude directory

March 26, 2009 at 15:46:41
Specs: Windows XP
I'm having trouble and hope you can help. Here's my batch file.

@echo off
cls

if %1 == C: goto CONT_C
if %1 == c: goto CONT_C
if %1 == D: goto CONT_D
if %1 == d: goto CONT_D
if %1 == E: goto CONT_E
if %1 == e: goto CONT_E
goto PREQUIT

:CONT_C
echo %1 Drive - Last Backup - %date% >>F:\backup.txt
xcopy %1\*.raw f:\C-Drive /S /E /H /R /Y
cd\
c:
cd\
goto QUIT

:CONT_D
echo %1 Drive - Last Backup - %date% >>F:\backup.txt
xcopy %1\*.raw f:\D-Drive /S /E /H /R /Y
cd\
c:
cd\
goto QUIT

:CONT_E
echo %1 Drive - Last Backup - %date% >>F:\backup.txt
xcopy %1\*.raw f:\E-Drive /S /E /H /R /Y
cd\
c:
cd\
goto QUIT

:PREQUIT
cls
Echo INVALID DRIVE SPECIFIED!
goto QUIT

:QUIT

As you can see, I run the backup with a parameter of C: D: or E: and it backs up only changed files into a corresponding directory on the F drive. It also appends the drive backed up and the date to a file called backup.txt. The problem I'm having is that the batchfile ends prematurely due to not being able to access or copy the \System Volume Information\ directory or files. I've been trying to find a way to exclude it. I've read other exclusion methods which creates exclude.txt which contains all the files in the directory wishing to be excluded but this isn't possible with this directory. Does anyone have any idea how I can accomplish it? Thank you for any suggestions.


See More: Dos Batch exclude directory

Report •


#1
March 26, 2009 at 21:49:01
[1] Nothing to do with DOS. This is no \System Volume Information\ directory in DOS.

[2] Do you need the /h ? If not, it might skip the \System Volume Information\ directory without it.

[3] If that doesn't work try the /c

[4] I see no point to a chunk like this:

cd\
c:
cd\
goto QUIT


nor this:

goto QUIT

:QUIT

========= try this
@echo off & setLocal EnableDelayedExpansion

goto :%1
goto :eof

:c
:d
:e

echo %1 Drive - Last Backup - %date% >>F:\backup.txt
echo xcopy %1:\*.raw f:\%1-Drive /S /E /c /R /Y


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

M2


Report •
Related Solutions


Ask Question