Helge said:
Hallo NG!
Once per week I generate a (backup-)folder named YYYYMMDD.
When there are 5 or more folders the oldest 5+-folder(s)
should be deleted. How can I achieve that?
I checked with the help-command at cmd-prompt, but didnt
succeed with the dir-, for- and other commands.
Sorry, it is to tricky for me.
Thanks.
Vy 73! Helge
- - - - - - - begin screen capture WinXP MCE 2005 SP2 - - - - - - -
c:\cmd>dir /ad \junkdir
Volume in drive C has no label.
Volume Serial Number is 44E5-91F9
Directory of c:\junkdir
04/09/2006 03:13 PM <DIR> .
04/09/2006 03:13 PM <DIR> ..
04/09/2006 03:13 PM <DIR> 20060329
04/09/2006 03:13 PM <DIR> 20060330
04/09/2006 03:13 PM <DIR> 20060401
04/09/2006 03:13 PM <DIR> 20060402
04/09/2006 03:13 PM <DIR> 20060403
04/09/2006 03:13 PM <DIR> 20060404
04/09/2006 03:13 PM <DIR> 20060405
04/09/2006 03:13 PM <DIR> 20060406
04/09/2006 03:13 PM <DIR> 20060407
04/09/2006 03:13 PM <DIR> 20060408
04/09/2006 03:13 PM <DIR> 20060409
0 File(s) 0 bytes
13 Dir(s) 218,433,523,712 bytes free
c:\cmd>demo\SaveFiveDirs
rd /s /q 20060404
rd /s /q 20060405
rd /s /q 20060406
rd /s /q 20060407
rd /s /q 20060403
rd /s /q 20060329
C:\CMD>wyllist demo\SaveFiveDirs.cmd
==========begin file C:\CMD\DEMO\SaveFiveDirs.cmd ==========
01. @echo off
02. pushd \junkdir
03. for /f "skip=5" %%a in (
04. 'dir /b /ad /o-d'
05. ) do echo rd /s /q %%a
06. popd
==========end file C:\CMD\DEMO\SaveFiveDirs.cmd ==========
- - - - - - - end screen capture WinXP MCE 2005 SP2 - - - - - - -
If this appears to do what you intend, remove the word 'echo' from
line 5.