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 to clean folders
Name: samcneal Date: December 20, 2004 at 06:11:22 Pacific OS: Windows 2003 CPU/Ram: Quad 4, 1 gig
Comment:
Anyone knows how to create a batch file to clean up a folder based on a certain number of days? I want to delete files older than 7 days but I don't know the syntax for date. I know how to delete files using the batch utility.
Name: dtech10 Date: December 21, 2004 at 15:29:39 Pacific
Reply:
Hi I wrote a batch for WinXP to delete files older than a certain number of days, as I'm english I guess than I would have to change the date variables in the batch file. ie this command typed at the dos prompt on my system "date /t" produces "21/12/2004". Your would produce "12/21/2004" is that correct if not what format doe's it produce. I'm not familar with Windows 2003 so I think it might work ok on your system.
0
Response Number 2
Name: FishMonger Date: December 21, 2004 at 21:55:28 Pacific
Reply:
Calculating past/future dates and differences between them is not an easy task for a batch file.
If you're interested, here's a Perl script that would be cleaner than the batch file. This uses the parent directory as its starting point and does a recursive desent into each subdir deleting any file that was modified 7 or more days ago.
#!perl -w
use strict; use File::Find;
my $dir = 'path/to/parent/dir';
finddepth(\&file_be_gone, $dir);
sub file_be_gone {     return if /^\.\.?/;     if ((_M $_) >= 7) { unlink $File::Find::name; } }
0
Response Number 3
Name: FishMonger Date: December 21, 2004 at 22:05:41 Pacific
Summary: I need a batch file to open folders in c:TempFonts and then move and delete any .ttf files therein to s:Projects\_fonts. I am a newbie to DOS batch files and any help will be greatly appreciated. Than...
Summary: OK. Got this cracked now. SN, many thanks for the suggestions & pointers re use of .inf files. I've now managed to execute automated registry clearances with a batch file using both the .reg and .i...
Summary: I have a folder [folder_a] that contains various other folders (different levels)and different folder names, each contains a single image with same name [image.jpg] ....I need a script or programe th...