DeleteFilesOlderThan deletes files matching the passed file pattern and which are older than the given time specification from a folder.
DeleteFilesOlderThan /time=<time specification> /path=<folder to delete files from> [/filepattern=<files to delete>[;<files to delete>]] [/subfolders=0|1] [/filessmallerthan=|/filesgreaterthan=<file size>] [/recyclebin=0|1] [/readonly=0|1] [/processpriority=i|b] [/hideconsole=0|1] [/lastaccess=0|1]
or
DeleteFilesOlderThan /t=<time specification> /p=<folder to delete files from> [/f=<files to delete>[;<files to delete>]] [/s=0|1] [/fst=|/fgt=<file size>] [/rb=0|1] [/r=0|1] [/pp=i|b] [/hc=0|1] [/la=0|1]
e.g.
-
DeleteFilesOlderThan /time=2d /path=D:\MyTarget
Delete all files in folderD:\MyTarget
which are older than two days. -
DeleteFilesOlderThan /t=3w /p=C:\MyTarget\Data /f=*.txt /s=1
Delete all*.txt
files in folderC:\MyTarget\Data
and all subfolders (/s
) which are older than three weeks.
Pressing <ESC> any time will exit the program execution.
/t
or/time
Time specification (see below)/p
or/path
(Start) folder/f
or/filepattern
File pattern. If omitted, all files are scanned (equals/f=*.*
)./s
or/subfolders
Recurse subfolders yes(1) or no(0). If omitted, only the folder passed via/p
is scanned for matching files (equals/s=0
)./rb
or/recyclebin
Delete to recycle bin instead of permanently delete. If omitted, defaults to 0 = delete files permanently./r
or/readonly
Delete readonly files? If omitted, defaults to 0 = don't delete readonly files./pp
or/processpriority
Set this process' priority to Idle ('i' = lowest possible) or Below normal ('b') in order to consume less (mainly CPU) resources./hc
or/hideconsole
Hide the application's (console) window? Yes(1) or no(0). Defaults to no./la
orlastaccess
Compare to a file's LastAccessTime instead of its LastWriteTime./fst
or/filessmallerthan
Only delete files smaller than the specified file size (see below how to pass file sizes)./fgt
or/filesgreaterthan
Only delete files greater than the specified file size (see below how to pass file sizes).
Please note that you may only use either /fst
or /fgt
. You can't use both parameters. If you happen to pass both parameters, the last one 'wins'.
You may specify more than one file pattern for the parameter /f
by using ; (semicolon) as a separator, e.g.
/f=*.doc;*.rtf
= deletes all *.doc
and all *.rtf
files from the specified folder.
/f=Backup*.bak;Log*.trn
= deletes all Backup*.bak
and all Log*.trn
files from the specified folder.
d = day e.g. 1d
w = week e.g. 2w
m = month e.g. 3m
y = year e.g. 4y
none = Byte, e.g. 100
kb = Kilobyte, e.g. 100kb
mb = Megabyte, e.g. 100mb
gb = Gigabyte, e.g. 100gb
tb = Terabyte, e.g. 100tb
Please note: 1 KB = 1024 byte, 1 MB = 1024 KB etc.
DeleteFilesOlderThan writes all output to STDOUT. So in order to produce a log file of its actions, simply redirect the output to a file via '> log_file_name'.