Thanks
@echo off
rem REMOVE the 5th backup
rd /S /Q 5
rem MOVE 4th backup to 5th
mv 4 5
rem MOVE 3rd backup to 4th
mv 3 4
rem MOVE 2nd backup to 3rd
mv 2 3
rem MOVE 1st backup to 2nd
mv 1 2
rem COPY new backup to 1st
xcopy /I *.* 1
--
Luuk
Thanks now why didn't I think of that.. :)
Again THANKS
Unix port, by the sound of the name. Though the "rd" synttax is fine in XP.
Personally, I believe that this would be easier - but it might depend on
your OS, and assumes that directories 1,2,3,4,5 exist
This solution developed using XP
It may work for NT4/2K
----- batch begins -------
[1]@echo off
[2]rd /s /q 5
[3]ren 4 5
[4]ren 3 4
[5]ren 2 3
[6]ren 1 2
------ batch ends --------
Lines start [number] - any lines not starting [number] have been wrapped and
should be rejoined. The [number] that starts the line should be removed
Naturally, your backup should then be made to 1
83} How to archive files with a rotation of five latest generations?
http://www.netikka.net/tsneti/info/tscmd083.htm
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FI-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
Here is a snip that I use for a Cascading Rename to keep 7 days.
sKurt
*snip
::+=(242)=================================+
::| CASREN (CASCADING RENAME) BACKUP FILE |
::+=======================================+
CD\%b%%a%-BU>NUL
::+=(243)====================================+
::| First, does the CA1231BU.ZIP file exist? |
::| If it doesn't exsist, go create it now |
::+==========================================+
[01] IF NOT EXIST %b%%a%%d%BU.ZIP GOTO :_DO_ZIP_LOCAL >NUL
[02] IF "%D1%"=="/DEBUG" XSET /COLOR YELLOW /PROMPT "CA1231BU.ZIP
CASREN FILE PROCESSING (243)"
::+=(244)==================+
::| If the directories are |
::| NOT there, create them |
::+========================+
IF NOT EXIST OLD01\NUL MD OLD01 >NUL
IF NOT EXIST OLD02\NUL MD OLD02 >NUL
IF NOT EXIST OLD03\NUL MD OLD03 >NUL
IF NOT EXIST OLD04\NUL MD OLD04 >NUL
IF NOT EXIST OLD05\NUL MD OLD05 >NUL
IF NOT EXIST OLD06\NUL MD OLD06 >NUL
IF NOT EXIST OLD07\NUL MD OLD07 >NUL
::+============================================================+::
IF NOT EXIST OLD06\%b%%a%%d%BU.ZIP GOTO OLD05
IF EXIST OLD07\%b%%a%%d%BU.ZIP ATTRIB -R OLD07\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD07\%b%%a%%d%BU.ZIP DEL OLD07\%b%%a%%d%BU.ZIP >NUL
MOVE OLD06\%b%%a%%d%BU.ZIP OLD07 >NUL
::+============================================================+::
IF NOT EXIST OLD05\%b%%a%%d%BU.ZIP GOTO OLD04
IF EXIST OLD06\%b%%a%%d%BU.ZIP ATTRIB -R OLD06\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD06\%b%%a%%d%BU.ZIP DEL OLD06\%b%%a%%d%BU.ZIP >NUL
MOVE OLD05\%b%%a%%d%BU.ZIP OLD06 >NUL
::+============================================================+::
IF NOT EXIST OLD04\%b%%a%%d%BU.ZIP GOTO OLD03
IF EXIST OLD05\%b%%a%%d%BU.ZIP ATTRIB -R OLD05\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD05\%b%%a%%d%BU.ZIP DEL OLD05\%b%%a%%d%BU.ZIP >NUL
MOVE OLD04\%b%%a%%d%BU.ZIP OLD05 >NUL
::+============================================================+::
IF NOT EXIST OLD03\%b%%a%%d%BU.ZIP GOTO OLD02
IF EXIST OLD04\%b%%a%%d%BU.ZIP ATTRIB -R OLD04\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD04\%b%%a%%d%BU.ZIP DEL OLD04\%b%%a%%d%BU.ZIP >NUL
MOVE OLD03\%b%%a%%d%BU.ZIP OLD04 >NUL
::+============================================================+::
IF NOT EXIST OLD02\%b%%a%%d%BU.ZIP GOTO OLD01
IF EXIST OLD03\%b%%a%%d%BU.ZIP ATTRIB -R OLD03\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD03\%b%%a%%d%BU.ZIP DEL OLD03\%b%%a%%d%BU.ZIP >NUL
MOVE OLD02\%b%%a%%d%BU.ZIP OLD03 >NUL
::+============================================================+::
IF NOT EXIST OLD01\%b%%a%%d%BU.ZIP GOTO CURR
IF EXIST OLD02\%b%%a%%d%BU.ZIP ATTRIB -R OLD02\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD02\%b%%a%%d%BU.ZIP DEL OLD02\%b%%a%%d%BU.ZIP >NUL
MOVE OLD01\%b%%a%%d%BU.ZIP OLD02 >NUL
::+============================================================+::
IF EXIST OLD01\%b%%a%%d%BU.ZIP ATTRIB -R OLD01\%b%%a%%d%BU.ZIP >NUL
IF EXIST OLD01\%b%%a%%d%BU.ZIP DEL OLD01\%b%%a%%d%BU.ZIP >NUL
IF EXIST %b%%a%%d%BU.ZIP MOVE %b%%a%%d%BU.ZIP OLD01 >NUL
::+============================================================+::
::+=(244)===========================+
::| IF BU.ZIP doesn't exist, create |
::+=================================+
:_DO_ZIP_LOCAL
[01] IF "%D1%"=="/DEBUG" XSET /COLOR WHITE /PROMPT "NETBACK - IF BU.ZIP
DOESN'T EXIST, CREATE (244)"
*snip
--
oeps, indeed gnu, but MOVE should word also... ;-)
D:\TEMP\temp>mv --version
mv (GNU coreutils) 6.10
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Parker, David MacKenzie, and Jim Meyering.
--
Luuk