WinBatch® Technical Support Forum

Archived Boards => WinBatch Script Exchange => Topic started by: menor59 on September 16, 2014, 07:18:28 AM

Title: Batch File to Create 25 backs up then at the 26 remove the first...Circularoty..
Post by: menor59 on September 16, 2014, 07:18:28 AM

:: --- BATCH SCRIPT START ---
:: --- Batch File to Copy and create new folder for AMAG Backup's ---
:: --- Created By: Me ---
@echo off
net use Z: \\smcbackup\amag /PERSISTENT:YES
setlocal enabledelayedexpansion
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set target=Z:\AMAG Backup\GLOBALSRV\%%C-%%B-%%A-AMAG Back Up
xcopy "D:\Program Files\Microsoft Sql Server\MSSQL\Backup\*" "%target%\" /E /-Y
setlocal
set source=Z:\AMAG Backup\GLOBALSRV
pushd "%source%"
FOR /F "skip=25 delims=" %%a IN ('DIR /B /AD 25?????? ^| SORT /R') DO RD /S /Q "%%a"
popd
endlocal
:: --- BATCH SCRIPT END ---


Somethings not working right...I believe its here...

FOR /F "skip=25 delims=" %%a IN ('DIR /B /AD 25?????? ^| SORT /R') DO RD /S /Q "%%a"


I need it do do run concurent 25 folders...then at the 26th time it runs it removes the 1st folder to create the 26...the next day to remove the 2nd and create the 27th...Basically a circulatory back up that keeps the newest 25 folders always...

This Batch file runs Daily once a day...
Title: Re: Batch File to Create 25 backs up then at the 26 remove the first...Circularoty..
Post by: snowsnowsnow on September 17, 2014, 06:50:57 AM
Looks like you're in the wrong place.  This forum is for WinBatch, not for "ordinary" DOS/Windows "batch".

You might try:

news://alt.msdos.batch.nt