xcopy with exclude switch

Microsoft Windows server 2003
April 8, 2010 at 09:27:13
Specs: Windows server 2003
I'm trying to write a batch file to copy folders from my D drive to an external G drive using xcopy. I want to exclude 4 folders. I can't get the exclude switch to work properly. Here's what I have written: xcopy D:\ G:\Backup\FullBackup /s /h /c /exclude:D:\Folder1[+Folder2][+Folder3][+Folder4] I'm using Server 2003. Can anyone help? Thanks in advance.

See More: xcopy with exclude switch

Report •

April 8, 2010 at 12:18:19
from xcopy /?

Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.

I don't see how you can exclude folders as you desire. Wait for others to reply with suggestions.

Report •

April 9, 2010 at 09:47:32
OK Thanks for your help anyway!

Report •

July 16, 2010 at 07:45:05
Ok, I use Xcopy with exclude all the time to back up my files from my PC with XP Pro to a 500 Gig USB Portable drive with a program I wrote to back up what I want from my C: drive.
First in the program I create a Directory called BACKUP on the Portable drive also have the backup keep a log file so I can check when it starts and stops, and for messages and so on.
After setting the params, one of the lines says:

XCOPY "C:\Documents and Settings" "%DAILY_DIR%\Documents and Settings" /D:07-15-2010 /s /y /i /h /Exclude:excludefile4.txt

In the excludefile4.txt the format can look like this:
\Local Settings\Temp\

So you skip over folders and also specific files and types of files.

Put your xcopy command in a one line file if you want and call it myxcopy.cmd and put your exclude file exc.txt in the same directory. Dbl click on the cmd file and watch it run. If you have to, put pauses in it and adjust your exclude file till it runs as you want it..

Report •
Related Solutions

Ask Question