Batch file to delete old backup

  • Thread starter Anders Hellstrom
  • Start date
A

Anders Hellstrom

Presently I am using batch files for backing up my 4000 + work files to a
second hard drive. The batch files are executed from icons on the desktop.
The work files are stored in folder "All Data Files" and many subfolders.

To make a complete backup I use a command line:
Xcopy C:\"All Data Files" F:\"All Data Files" /c/e/h/k/r/s

To back up the files only after a certain date, I use a command line:
Xcopy C:\"All Data Files" F:\"All Data Files" /d:12-31-2005/c/e/h/k/r/s

When making a complete backup, I would like to add a line in the batch file
which will delete all subfolders and files located in folder F:\All Data
Files\..
I have tried the DOS command DEL, but I have not been able to make it work
with all subfolders and files.

My Operating System is Windows XP Home Edition with Service Pack 2.
Any help will be greatly appreciated

Anders Hellstrom
 
B

billious

Anders Hellstrom said:
Presently I am using batch files for backing up my 4000 + work files to a
second hard drive. The batch files are executed from icons on the desktop.
The work files are stored in folder "All Data Files" and many subfolders.

To make a complete backup I use a command line:
Xcopy C:\"All Data Files" F:\"All Data Files" /c/e/h/k/r/s

To back up the files only after a certain date, I use a command line:
Xcopy C:\"All Data Files" F:\"All Data Files" /d:12-31-2005/c/e/h/k/r/s

When making a complete backup, I would like to add a line in the batch
file
which will delete all subfolders and files located in folder F:\All Data
Files\..
I have tried the DOS command DEL, but I have not been able to make it work
with all subfolders and files.

My Operating System is Windows XP Home Edition with Service Pack 2.
Any help will be greatly appreciated

Anders Hellstrom

Instead of DEL, try using

RD

RD/? will show the way..

RD/s/q "foldername"

should cause "foldername" to be "softly and suddenly vanished away"

HTH

....Bill
 
A

Anders Hellstrom

Thank you Bill,
I ended up with a batch file which includes:
Rmdir/s/q G:\"All Data Files"
Mkdir G:\"All Data Files"
Xcopy C:\"All Data Files" G:\"All Data Files" /c/e/h/k/r/s

This works just fine,
Anders
 
A

Anders Hellstrom

billious said:
Instead of DEL, try using

RD

RD/? will show the way..

RD/s/q "foldername"

should cause "foldername" to be "softly and suddenly vanished away"

HTH

...Bill
Thank you Bill,
I ended up with a batch file which includes:
Rmdir/s/q G:\"All Data Files"
Mkdir G:\"All Data Files"
Xcopy C:\"All Data Files" G:\"All Data Files" /c/e/h/k/r/s

This works just fine,
Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top