Simple Bat question – Selectively delete files?

Home Forums Scripting General Scripting Simple Bat question – Selectively delete files?

Viewing 1 post (of 1 total)
  • Author
  • Avatar

    A quick question, perhaps my google search terms are wrong by I cannot seem to find what I am looking for. I am writing a bat script which will run at logon and copy all files from a users U drive to U drive while excluding all pst files and folders named outlook/windows. This part is fine.

    What I would then like to do is go back and recursively delete all the files moved except for those excluded in the original xcopy. I tried to do this by:

    xcopy “M:*.*” “U:Old M Drive” /s /EXCLUDE:T:exclude.txt
    call “T:remove.bat”

    where remove.bat is

    for %%G in (XCOPY /u/n/l/y/s “M:” “U:Old M Drive”) do del “%%G”

    This, however, does not delete any directories. Does anyone have any suggestions? This seems like it should be an easy function, however, I cannot find any exclude parameters.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.