Computing.Net > Forums > Disk Operating System > Trying to purge files based on Date

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.

Trying to purge files based on Date

Reply to Message Icon

Name: TKaz
Date: August 26, 2003 at 12:06:02 Pacific
OS: Win 2000 cmd prompt
CPU/Ram: 2.4 GHz & 2 GB Ram
Comment:

Hello.

I'm trying to write a batch file to purge files based on how old they are.

The solution I've had recommended to me involves the following command:
DIR \ | find /I "/" > del.log

The code then uses the result to find out the day, month, and year.

My problem is - the find command doesn't work properly. I don't think I have find in my cmd environment (note: I'm running Win 2000).
If I type Find /? at the promt it says Find: unable to access "/?"

I found a thread called "I'm Deleting Files by Date??" that recommended using xcopy to copy the files to be kept and then delete the rest, but this method is not an option for me due to the immense number of files I'm dealing with.

Any ideas out there?



Sponsored Link
Ads by Google

Response Number 1
Name: Brian HANLON
Date: August 29, 2003 at 05:26:42 Pacific
Reply:

At URL: http://home.mnet-online.de/horst.muc/ you'll find:

LMOD (a 12 Kb download)
Versatile line/list modification tool to generate lists of commands, set variables to anything extracted from (DOS) output, and more.. Win NT/2000 compatible.

and also:

ISDATE (a 3 Kb download)
IsDate compares two dates, including date tags of files and directories, TODAY. Date format acc. to COUNTRY. Optional difference (plus/minus days).

Example: IsDate C:\arc\foo.txt before today-7

The result (TRUE/FALSE) is returned by errorlevel.

Features:
LFN support (Win9x/2000)
Comparison operators: [not] =, equal, before, after
Internal calculation of day count since Jan 1, 1901 (up to 2079)

By utilising these to generate a BATch file "on the fly" from a DIR path\filespec.ext /O:N /-V result piped to either an intermediate file or directly to LMOD for pre-processing, you'll achieve the result you want.

Use LMOD to parse the DIR listing, and IsDate to make the decision on deletion. - LMOD would be used to take the DIR listing and convert it into a BAT file which would include the IsDate command for each file and actually achieve the deletion.

To demonstrate the Parsing of LMOD, once you have a copy in your path, do:

DIR C:\WINDOWS\*.TXT /O:N /-V

and compare that to the output of:

DIR *.TXT /O:N /-V|FIND "/"|LMOD /L* [1,8 R8].[10,3 R3] is [17,10 R10] bytes long, LFN is [47]

That should demonstrate the usage and flexibility of LMOD.

(Horst has some damned useful stuff at his site!)

Baldy


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Trying to purge files based on Date

Program to check file size www.computing.net/answers/dos/program-to-check-file-size/13835.html

renaming files but exclude newest www.computing.net/answers/dos/renaming-files-but-exclude-newest/13809.html

Removing files based on creation date www.computing.net/answers/dos/removing-files-based-on-creation-date/10389.html