Computing.Net > Forums > Programming > Batch file , need help urgently

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file , need help urgently

Reply to Message Icon

Name: elroth
Date: February 12, 2008 at 22:32:04 Pacific
OS: Windows
CPU/Ram: ram 1 GB
Product: Dell
Comment:

I need a batch file script which delete a file within D:\NEW\MINE\K based on the modified date.if the modified date is older than 3 months then the file is deleted.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 13, 2008 at 01:36:09 Pacific
Reply:

If you scout around thiis forum you'll see that 'date math' comes up at least a few times a month. It's never a happy ending.

To make any headway, you'll need to giive EXACT OS and date layout.

<font color


0

Response Number 2
Name: elroth
Date: February 13, 2008 at 03:13:05 Pacific
Reply:

Well i am quiet new to batch scripting , so i would be really helpful if you can provide a batch file for my requirement.
My OS is WINDOWS XP
Modified Date Layout : dd/mm/yyyy format like 2/12/2008.
This modified date should be compared to the current date , and if it is found to be 3 months older, then it should be deleted.


0

Response Number 3
Name: Mechanix2Go
Date: February 13, 2008 at 04:44:58 Pacific
Reply:

Do a DIR and post a few lines.

Miine shows:


13-02-2008 16:31 816 newfile
13-02-2008 16:29 766 MYFILE
13-02-2008 16:31 258 AB.BAT

::=====================


<font color


0

Response Number 4
Name: FishMonger
Date: February 13, 2008 at 08:58:05 Pacific
Reply:

Why do people always want to use the wrong tool for their required task?

You should use a more appropriate language, such as Perl or Python or VB.


0

Response Number 5
Name: elroth
Date: February 13, 2008 at 20:11:31 Pacific
Reply:

Well the format is same that you have provided. i am not quiet acquainted with the other languages like perl. i would like to know, if this can be done using a batch file. if yes could you please provide me one to meet the requirements.


0

Related Posts

See More



Response Number 6
Name: FishMonger
Date: February 13, 2008 at 21:35:37 Pacific
Reply:

I'm sure M2 will be able to work up a batch file, but in the mean time, here's an example Perl script.


#!perl

use strict;
use warnings;
use constant DAYS => 90;

foreach my $file ( <D:/NEW/MINE/K/*> ) {
if ( -M $file > DAYS ) {
print "Deleting $file\n";
unlink $file or warn "failed to delete $file $!\n";
}
}

The definition/calculation of a month could vary a bit since a month varies between 28 - 31 days. I chose to use 90 days to equal 3 months


0

Response Number 7
Name: elroth
Date: February 14, 2008 at 04:22:01 Pacific
Reply:

thanx fishmonger for the perl code, but actually i require a batch file script,if any one of u can provide me one.


0

Response Number 8
Name: elroth
Date: February 15, 2008 at 02:30:29 Pacific
Reply:

sorry guys , i am not being able to work with that perl script. batch file , i can work on. i would be happy , if you can meet my requirement


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file , need help urgently

Batch File --- need help www.computing.net/answers/programming/batch-file-need-help/15889.html

Simple Batch File command help www.computing.net/answers/programming/simple-batch-file-command-help/16568.html

Batch file to kill IE www.computing.net/answers/programming/batch-file-to-kill-ie-/14846.html