IF EXIST filename.bak REN filename.bak filename_%date:~4,2%-
%date:~7,2%-%date:~10%.bak
Any suggestions?
Certainly.
First, try alt.msdos.batch.nt as NT+ batch commands are significantly
different from DOS/9x which is the target for alt.msdos.batch.
Then read previous articles and solutions offered. This question gets asked
in various forms about once or twice per week.
The basic solution would be something line
for /f "skip=?tokens=*" %%i in ( ' dir /b /o:-d filename*.bak ' ) do ECHO
del "%%i"
where
ECHO is there to show what the batch would do. Once you're satisfied it's
acting correctly, take the ECHO keyword out to activate the delete
? is replaced by the number of generations you want to keep
Note also that it's considered wiser to format your date/time portion as
YYYYMMDDHHMMSSHS since that way the date format is obvious to everyone,
default sorting by name automatically sorts by date and there becomes no
need to ask significant questions like "what date/time format do you use?"
Also, see Timo Salmi's FAQ (see his sig) about dealing with date formatting.
The scheme you have chosen to use is not necessarily universally applicable
as the format returned by %date% depends on individual user settings. This
may or may not be significant in your case.
Happy batching!
> First, try alt.msdos.batch.nt as NT+ batch commands are significantly
> different from DOS/9x which is the target for alt.msdos.batch.
With as many times that this group redirection information is posted per
week, one might think Google posters should have read it at least once
before posting. :-(
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
> Any suggestions?
*** This is not a Windows group, but for any version of DOS or Windows:
XXCOPY C:\BACKUP\*.* /DB8D /RS
This will remove source (files) in the BACKUP directory that are 8 or
more days old.
One or more links to XXCOPY can be found at:
http://www.chebucto.ca/~ak621/DOS/Websites.html
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/