Wednesday, October 10, 2007

Delete all files which exist in source

This is useful after backing up files to CD/DVD if you then want to delete everything which has been copied.

d:\ is the directory containing filenames to be deleted.

The current directory should be the one where the files to be deleted exist.

First, to remove any hidden/system/read-only attributes:

attrib -h -s -r * /s

Then delete the files:

for /r d:\ %f in (*) do del ".%~pnxf"

No comments: