Copyright © 2003-2010 by Prof. Timo Salmi  
Last modified Fri 23-Apr-2010 20:15:31

Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index

This page is edited from the 1cmdfaq.txt faq-file contained in my tscmd.zip command line interface (CLI) collection. That zipped file has much additional material, including a number of detached .cmd script files. It is recommended that you also get the zipped version as a companion.

Please see "The Description and the Index page" for the conditions of usage and other such information.

83} How to archive files with a rotation of five latest generations?

I would like to archive some files periodically but only keep the last five iterations. The directories would ideally have date names. I know how to get a date into a directory name but I'm having a bit of trouble trying to figure out how to delete the oldest directory.

Such a backup rotation uses moves or renames. Below is the logic. The commands (e.g. zipping or whatever) are easily written once the simple logic sinks in:
  archive4 --> archive5
  archive3 --> archive4
  archive2 --> archive3
  archive1 --> archive2
  delete archive1
  Do the new archiving to archive1 (optionally with dates)

References/Comments: (If a Google message link fails try the links within the brackets.)
  Google Groups May 20 2008, 9:00 am [M]