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,011 of 42,547    |
|    justin.lamantia@gmail.com to All    |
|    Re: Batch File to Create 25 backs up the    |
|    18 Sep 14 10:51:06    |
   
   >   
   > > Basically a circulatory back up that keeps the newest 25 folders always...   
   >   
   >   
   >   
   > Test this - it changes to a folder and then lists the oldest folders if   
   there are more than 25   
   >   
   > folders in there. The && ensures that the FOR command only runs if the   
   folder is located.   
   >   
   >   
   >   
   > The key is to sort the DIR by reverse date using /O-D   
   >   
   >   
   >   
   > @echo off   
   >   
   > pushd "c:\folder" && FOR /F "skip=25 delims=" %%a IN ('DIR /B /AD /O-D') DO   
   echo RD /S /Q "%%a"   
   >   
   > pause   
   >   
   >   
   >   
   >   
   >   
   > Remove the echo to let it delete the folders.   
      
   That didnt work...   
      
   --- 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