Advertisement

10.09.2008 at 12:32AM PDT, ID: 23800103 | Points: 500
[x]
Attachment Details

leaving a folder out of a batch file script

Asked by nibby in Windows Batch Scripting

Tags: ,

Hi, Ive got a batch file that is backing up the contents of the D drive. I want to leave out a specific folder on that drive from backing up each time. Is this possible? The script is below.
Many thanks

@echo off
set error=
rem Set backup location
set dest=G:\Ddrivebackuplive
 
rem Set source to backup
set source=D:
 
mkdir %dest% 2>NUL
REM Copy full backup if backuplog.txt doesn't exist
if exist "%dest%\backuplog.txt" goto skipfull
  echo FULL BACKUP %date% %time% by %username% > "%dest%\backuplog.txt"
  xcopy /c/s/e/y "%source%\*.*" "%dest%"
  if errorlevel 1 set error=Full Copy (%errorlevel%)
:skipfull
 
REM Copy changed files
echo COPY CHANGES %date% %time% by %username% >> "%dest%\backuplog.txt"
xcopy /d/c/s/e/y "%source%\*.*" "%dest%"
if errorlevel 1 set error=%error%Changes (%errorlevel%)
 
if not "%error%"=="" echo There was an error %error%
if not "%error%"=="" echo There was an error %error% >>"%dest%\backuplog.txt"
echo Backup completed.  Press Any Key to end.
pause >NUL
START /WAIT "" "%dest%\backuplog.txt"
cls
exitStart Free Trial
 
Loading Advertisement...
 
[+][-]10.09.2008 at 01:25AM PDT, ID: 22676461

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 - Hierarchy / EE_QW_2_20070628