Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.logThe 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?

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

![]() |
![]() |
![]() |

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