4

I'm trying to use ROBOCOPY to move all files, folders, and subdirectories from one location to another. There are some files that SHOULD NOT be moved. I want to store a list of these files that are NOT to be moved in a text file.

What syntax would the robocopy be for 1. The robocopy command? 2. The syntax of the files for exclusion. As in does the path need to be absolute?

I have looked around but all the posts seem to tip toe around the idea

ROBOCOPY ^
"C:\SOURCE" ^
"C:\TARGET" ^
/E 


ExclusionList.txt
-file1.txt
-file2.txt

If i just need /XF pointing to the exclusion file? or does /XF point at each exlcuded file?

or do I have to do this with the :

/JOB:jobname : Take parameters from the named JOB file.

but how do I use /JOB.... would it be a text file with the extension .JOB... and if so how can I use variables from there.

Thanks,

The_BMan
  • 105
  • 11
  • XF is not an exclusion file. Xcopy does use exclusion file. – Squashman Feb 16 '17 at 16:07
  • 1
    The easiest way to use the `/job` is to prepare a aproximate command, execute it with the `/L` to only execute a list and the `/SAVE:file` to generate a job file. Now, edit the `.rcj` and customize it. Once done use the `/job:file` to process the job defined in the file. – MC ND Feb 16 '17 at 17:09

1 Answers1

1

If you don't have very many files for exclusion, then you may be able to generate the list as a variable to include in the /XF option.

@Echo Off
SetLocal EnableDelayedExpansion

Set "exList=C:\Users\The_BMan\Desktop\ExclusionList.txt"

Set "xFiles="
For /F UseBackQDelims^=^ EOL^= %%A In ("%exList%"
) Do If Not Defined xFiles (Set xFiles="%%~A") Else Set xFiles=!xFiles! "%%~A"

Echo( /XF %xFiles%

Timeout -1
Compo
  • 36,585
  • 5
  • 27
  • 39