-1

Currently have a GPO that calls a batch file at logon, that copyies files from one folder to another:

Robocopy "C:\logon" "X:\user1" /mir /r:1 w:1
Exit

This overwrites all the files in the destination, which is what I want, but I need to exclude one file, call if file1, if it already exists in the destination. So user1 contains all the files from C:\logon, it will overwrite all but file1. New user2 doesnt contain any, it will copy all contents, including file1 into the X:\user2 folder.

Can robocopy handle such a request? Or would I be looking at a different solution, that hopefully won't impact logon time too much.

Thank you.

soMuch2Learn
  • 333
  • 1
  • 6
  • 16

1 Answers1

0

I'm not aware of a switch in robocopy to do that, but you can test for the file, and invoke robocopy with different options to accomplish that result:

if not exist x:\user1\file1.txt Robocopy "C:\logon" "X:\user1" /mir /r:1 w:1
if exist x:\user1\file1.txt Robocopy "C:\logon" "X:\user1" /mir /r:1 w:1 /xf file1.txt
Clayton
  • 4,523
  • 17
  • 24
  • You don't even need the conditional here. Just run it with the /xf flag always. If the file exists, it will be excluded. If it doesn't, it will still be excluded because it doesn't exist. – Ryan Bolger Jun 17 '16 at 14:55
  • If I understood the question, he said if it does not exist he does want it copied. He wrote ...New user2 doesnt contain any, it will copy all contents including file1... – Clayton Jun 17 '16 at 15:19
  • You're right. I totally switched it around in my head while reading. – Ryan Bolger Jun 17 '16 at 17:35