1.

Solve : Backing up: Deleting files that aren't in original?

Answer»

I have an external harddrive, and I want to use a batch file to backup my DATA PERIODICALLY. What I have right now follows the FORMAT

XCOPY "C:\Documents and Settings\Owner\My Documents\My Videos" "M:\My Videos" /dhsyir

Which is nice, since it only copies/overwrites updated files. But what if I rename/move files on my computer? Then everything will get mixed up, REDUNDANT, etc.

Is there a way to delete files/folders from the M drive that aren't in the corresponding C folders? The two trees being compared have different roots, too... I tried looking into the FOR commands, but I got mixed up...

And on a related note, how do I format the output of
FOR /R "C:\Documents and Settings\Owner\My Documents\My Videos" %%i IN (*.*) do echo %%i >> test.txt
so that "C:\Documents and Settings\Owner\My Documents\My Videos" is NOT displayed? I only need folder names below that current directory.The relationship between copied files is thin at best. Moving/renaming files after making the copies throws in a complication that most utilities cannot resolve. You didn't mention your OS but if your machine can support it, try using SyncToy.

For the XCOPY this MIGHT work:

FOR /R "C:\Documents and Settings\Owner\My Documents\My Videos\*" %%i IN (*.*) do echo %%i >> test.txt

8-)Sorry, XP SP2.

Thanks a bunch for SyncToy, it looks great.



Discussion

No Comment Found