Download FI.zip, an alternative to the DIR command, which provides file age and size filtering, security, device, alternate data streams, and file link information.
When you type fi /?, you receive:
Version 0.13, Copyright (C)2002, Frank P. Westlake. Prints a list of files. FI \[options\] file\[s\] options\] file\[s\] \[. . . file\[s\] May include wild cards. Use the current directory indicator (.) to refer to a directory, ex: FI C:\temp\. Options, must precede 'file\[s\]': /A Attribute filter, Prints only the files with specified attributes. Ex: /A+SH-R (prints only the files with S and H but without R) /B Prints only the file name. /C Format numbers with a separator (default). Use /-C to disable. /D Print information on the device, for example: /D C: or \\. /G\[A|C|W\]""value\[/divisor\] Filters files by age in days. If '/divisor' is given, the day value is divided by that value (i.e. /24 for hours, /1440 for minutes). A=last access, C=creation, W=last write. Default is W. /H Include alternate data stream names. Printed as 'file:stream'. /L Include link index and the number of links as first two columns. /Q Include owner in brief listing or SIDs in verbose listing. /S Displays files in specified directory and all subdirectories. /T\[A|C|W\]\[G\] Print the time stamp of the file (default). Use /-T to disable. If 'G' is included print age instead of time. A=last access, C=creation, W=last write. Default is W. Examples: /TC /TCG /-T /V Print detailed information for each file. /X Use short file names. /Z\[""value\] Filters files by size (default). Use /-Z to disable printing of file size. The hyphen may be used to reverse the effect of an option. Comparison operators must be quoted somehow: /z"="0 "/z=0" /"z=0" Swirches may be predefined in an environment variable with the name of this program, for example 'SET FI.EXE=/LHQ-C'. The program name may vary. Codes displayed with trustee rights \[T:RWXDPO:PDF+\]: T=Either "Allows" or "Denies" the displayed permissions. R=Read, W=Write, X=Execute, D=Delete, P=Permissions write, O=Owner write. P=Primary object, D=Directories inherit, F=Files inherit, +=Propagated Examples: FI C:\WINNT\. FI "/g>7" /ash-r C:\WINNT\*.exe FI "/z=0" C:\WINNT\*.exe
Scripting ExampleIf you wanted to delete all the files in the C:\Folder directory whose last write date is greater than 30 days:
for /f "Tokens=*" %%f in ('fi /A-d /b /gw">"30 C:\Folder\*.*') do del /q "%%f"