|
|
|
Batch file , need help urgently
|
Original Message
|
Name: elroth
Date: February 12, 2008 at 22:32:04 Pacific
Subject: Batch file , need help urgentlyOS: WindowsCPU/Ram: ram 1 GBModel/Manufacturer: 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.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: February 13, 2008 at 01:36:09 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: elroth
Date: February 13, 2008 at 03:13:05 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Mechanix2Go
Date: February 13, 2008 at 04:44:58 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: FishMonger
Date: February 13, 2008 at 08:58:05 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: elroth
Date: February 13, 2008 at 20:11:31 Pacific
|
Reply: (edit)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.
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: FishMonger
Date: February 13, 2008 at 21:35:37 Pacific
|
Reply: (edit)I'm sure M2 will be able to work up a batch file, but in the mean time, here's an example Perl script. #!perluse 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
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: elroth
Date: February 14, 2008 at 04:22:01 Pacific
|
Reply: (edit)thanx fishmonger for the perl code, but actually i require a batch file script,if any one of u can provide me one.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: elroth
Date: February 15, 2008 at 02:30:29 Pacific
|
Reply: (edit)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
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|