Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
batch script to delete old files
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
fred.yingl...@gmail.com  
View profile  
 More options Feb 7 2008, 5:04 pm
Newsgroups: alt.msdos.batch
From: fred.yingl...@gmail.com
Date: Thu, 7 Feb 2008 14:04:36 -0800 (PST)
Local: Thurs, Feb 7 2008 5:04 pm
Subject: batch script to delete old files
I have a batch script that runs nightly on WinXP to rename backups
according to the date in a particular folder. My next step would be to
delete all of the backups that are more than 1 week old. Here is the
current script that I use to rename the files:

IF EXIST filename.bak REN filename.bak filename_%date:~4,2%-
%date:~7,2%-%date:~10%.bak

Any suggestions?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
billious  
View profile  
 More options Feb 7 2008, 9:18 pm
Newsgroups: alt.msdos.batch
From: "billious" <billious_1...@hotmail.com>
Date: Fri, 8 Feb 2008 10:18:59 +0800
Local: Thurs, Feb 7 2008 9:18 pm
Subject: Re: batch script to delete old files

<fred.yingl...@gmail.com> wrote in message

news:2f70f3b6-f4a3-4728-b755-748a013acb47@d70g2000hsb.googlegroups.com...

>I have a batch script that runs nightly on WinXP to rename backups
> according to the date in a particular folder. My next step would be to
> delete all of the backups that are more than 1 week old. Here is the
> current script that I use to rename the files:

> IF EXIST filename.bak REN filename.bak filename_%date:~4,2%-
> %date:~7,2%-%date:~10%.bak

> Any suggestions?

Certainly.

First, try alt.msdos.batch.nt as NT+ batch commands are significantly
different from DOS/9x which is the target for alt.msdos.batch.

Then read previous articles and solutions offered. This question gets asked
in various forms about once or twice per week.

The basic solution would be something line

for /f "skip=?tokens=*" %%i in ( ' dir /b /o:-d filename*.bak ' ) do ECHO
del "%%i"

where
ECHO is there to show what the batch would do. Once you're satisfied it's
acting correctly, take the ECHO keyword out to activate the delete
? is replaced by the number of generations you want to keep

Note also that it's considered wiser to format your date/time portion as
YYYYMMDDHHMMSSHS since that way the date format is obvious to everyone,
default sorting by name automatically sorts by date and there becomes no
need to ask significant questions like "what date/time format do you use?"

Also, see Timo Salmi's FAQ (see his sig) about dealing with date formatting.
The scheme you have chosen to use is not necessarily universally applicable
as the format returned by %date% depends on individual user settings. This
may or may not be significant in your case.

Happy batching!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Vargo  
View profile  
 More options Feb 7 2008, 11:40 pm
Newsgroups: alt.msdos.batch
From: "Todd Vargo" <tlva...@sbcglobal.netz>
Date: Fri, 08 Feb 2008 04:40:37 GMT
Local: Thurs, Feb 7 2008 11:40 pm
Subject: Re: batch script to delete old files

billious wrote:
> First, try alt.msdos.batch.nt as NT+ batch commands are significantly
> different from DOS/9x which is the target for alt.msdos.batch.

With as many times that this group redirection information is posted per
week, one might think Google posters should have read it at least once
before posting. :-(

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Bonner  
View profile  
 More options Feb 8 2008, 1:21 pm
Newsgroups: alt.msdos.batch
From: ak...@chebucto.ns.ca (Richard Bonner)
Date: Fri, 8 Feb 2008 18:21:35 +0000 (UTC)
Local: Fri, Feb 8 2008 1:21 pm
Subject: Re: batch script to delete old files

fred.yingl...@gmail.com wrote:
> I have a batch script that runs nightly on WinXP to rename backups
> according to the date in a particular folder. My next step would be to
> delete all of the backups that are more than 1 week old.
> Any suggestions?

***   This is not a Windows group, but for any version of DOS or Windows:

XXCOPY C:\BACKUP\*.* /DB8D /RS

   This will remove source (files) in the BACKUP directory that are 8 or
more days old.

   One or more links to XXCOPY can  be found at:

        http://www.chebucto.ca/~ak621/DOS/Websites.html

         Richard Bonner
http://www.chebucto.ca/~ak621/DOS/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google