View Single Post
  #1  
Old December 5th 08, 12:38 PM posted to microsoft.public.windowsxp.general
PhilHibbs
external usenet poster
 
Posts: 7
Default Deleting files from one directory that are not present in another

I'm trying to sync one directory with another. I've got an xcopy
command that makes sure that files on the source are present on the
target, but I also want to delete files on the target that are not
present on the source.

Currently my command looks like this:

for /R Z:\test1 %F in (*.*) do if not exist "X:%~pnxF" del "%F"

This works fine when I run it on the command prompt directly, but
doesn't work in a cmd file. I seem to remember something about having
to double up the % but I can't remember the details, I tried this in
various places but can't make it work. Any ideas?

Phil Hibbs.
Ads