Link to home
Start Free TrialLog in
Avatar of MrComputerIT
MrComputerIT

asked on

Can I mirror a directory with Robocopy, but leave two files in the destination directory that aren't in the source?

Hello :)

Here's what I'd like to do:

Say I have "c:\dirA" that has lots of files and subdirectories. I want to mirror that directory to "c:\dirB", adding new files/folders, deleting deleted files/folders, and updating changed files/folders. However, "c:\dirB" has two files in it "c:\dirB\File1.txt" and "c:\dirB\File2.txt" that I don't want deleted even though they are not in the source directory. Is there a way to do that with Robocopy? Any clever hacks you can think of to make this work?

Thanks!
Avatar of Arana (G.P.)
Arana (G.P.)

maybe you can set those 2 files to readonly and then perform your copy in a batch file

attrib +r c:\dirB\File1.txt
attrib +r c:\dirB\File2.txt
your robocopy command
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MrComputerIT

ASKER

I had no idea that the /xf switch could be used to exclude files from the destination. It worked perfectly! Thanks!