Mark Breen
marklbreen at gmail.com
Wed Jul 25 03:17:03 CDT 2012
Hello John I think I knew of ForFiles, but thanks for reminding us. Very useful Mark. On 20 July 2012 09:50, Tydda Jon - Slough <jon.tydda at lonza.com> wrote: > Thanks Mark - I spoke to my server guy, and he introduced me to the > concept of "Forfiles": > > forfiles /P "C:\folder" /S /M *.ekb /D -35 /C "cmd /c del @file" > > This searches the C:\folder location for any .ekb files older than 35 days > and deletes them. Pretty awesome stuff, and free with Windows 7! > > > Jon > > -----Original Message----- > From: dba-tech-bounces at databaseadvisors.com [mailto: > dba-tech-bounces at databaseadvisors.com] On Behalf Of Mark Breen > Sent: 20 July 2012 09:16 > To: Discussion of Hardware and Software issues > Subject: Re: [dba-Tech] Batch script help > > Hello John, > > If you are using SQL Server, take a look at expressmaint, it is opensource > and does everything you can ask for re backups on SQL Server. It is really > super. > > If Expressmaint does not do the job, then see see I am sorry that I cannot > credit the site I caught this snippit from, but I have been using it daily > for two years and it works great. > > Can you adjust it to do what you want ? > > <snip> > :: This file just sets the folder and then identifies the latest file and > then copys it. > > > @echo off > setLocal EnableDelayedExpansion > pushd C:\MyFolder\ > for /f "tokens=* delims= " %%a in ('dir/b/od *.sql') do (set newest=%%a) > copy "%newest%" C:\FilesToRestore\db.sql > > </snip> > > > Mark > > > > On 19 July 2012 10:34, Tydda Jon - Slough <jon.tydda at lonza.com> wrote: > > > Hi all > > > > > > I've created a scheduled task to copy local database backup files to a > > network drive so they get backed up for longer. That bit is easy. > > > > What I really want to do is to limit the folder to the last five > > backups, so that I'm not filling the file server (and all the hourly > > snapshots) with old data that won't ever be looked at again. > > > > I've searched for a script to delete the oldest file in a folder, but > > with no joy - I'm trying to do this with a batch command (Windows 7). > > > > Can anyone help? > > > > > > Jon >