Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,934 of 42,547    |
|    Herbert Kleebauer to Ammammata    |
|    Re: delete files except the latest of ev    |
|    15 Feb 21 18:50:17    |
   
   From: klee@unibwm.de   
      
   On 15.02.2021 15:22, Ammammata wrote:   
      
   >>> @echo off   
   >>> for %%i in (01 02 03 04 05 06 07 08 09 10 11 12) do (   
   >>> for /f "skip=1" %%j in ('dir /b o-n   
   >>> RSP_backup_202?_%%i_??_??????_???????.bak') do echo del %%j) 2>nul   
      
   > well, once removed the 'safety' echo, it does some deletions leaving just   
   > one file per month even if in an apparent random mode, I think there is a   
   > missing slash in dir /b o-n, should be dir /b /o-n   
   >   
   > let me try again, I worked on a copy ;)   
   >   
   > so, with the change it leaves just the first of each month, it's anyway a   
   > valid solution, thank you   
      
   Yes, the / was missing, but /o-n should leave the last of the month   
   whereas /on the first of the month.   
      
   If there are backups for more than a year, just specify the year which you   
   want to clean up:   
      
   @echo off   
   for %%i in (01 02 03 04 05 06 07 08 09 10 11 12) do (   
   for /f "skip=1" %%j in ('dir /b /o-n RSP_backup_2021_%%i_??_????   
   ?_???????.bak')   
   do echo del %%j) 2>nul   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca