LynchDev
LynchDev

Reputation: 813

Batch Script: Robocopy exclude files not working

Here is how I am creating and using the exclude file list:

:: Pull out parameters
set srcDir=%1 
set destDir=%2

:: Create exclude file
Set excludeFile=%temp%\exclude_list.txt

:: Populate exclude file
Echo.%srcDir%\web.config > %excludeFile%
Echo.%srcDir%\bin\*.* >> %excludeFile%
Echo.%srcDir%\custom\*.* >> %excludeFile%
Echo.%srcDir%\dataentry\custom\*.* >> %excludeFile%
Echo.%srcDir%\images\custom\*.* >> %excludeFile%

:: do a robust copy from source to dest
robocopy %srcDir% %destDir% /e /xf %excludeFile%

But none of this stuff is excluded in the final copy; am I doing something wrong?

Upvotes: 0

Views: 5776

Answers (2)

dbenham
dbenham

Reputation: 130829

The /XD and /XF options expect a list of paths to exclude, not the name of a file containing paths to exclude.

:: Pull out parameters
set srcDir=%1
set destDir=%2

:: do a robust copy from source to dest
robocopy %srcDir% %destDir% /e /xd .\bin .\custom .\dataentry\custom .\images\custom /xf .\web.config

I believe you need to use the /JOB or /IF option if you want to specify parameters in another file, though I haven't used those options.

Upvotes: 1

mjgpy3
mjgpy3

Reputation: 8947

Have you considered using xcopy? With it you can make an exclusion list, and it works very well.

Upvotes: 0

Related Questions