Tools@BasicAware

DeleteFilesOlderThan

Purpose

DeleteFilesOlderThan lets you delete files of a certain age. The number of files deleted is returned via the ERRORLEVEL environment variable.

Example in a batch file, assuming four files in the target folder which are older than two days:

DeleteFilesOlderThan /time=2d /path=c:\data\ztemp
ECHO From batch: %ERRORLEVEL% file(s) deleted.

... results in ...

• DeleteFilesOlderThan v1.4.2 •
Copyright © 2013-2016 by BasicAware. All rights reserved.
Written by Knuth Konrad

Time : 1d
Folder : .\data\
File pattern : *.tmp
Recurse subfolders: False
Verbose : False

-- Scanning folder .\data\
- File pattern: *.tmp
- Deleting sa5a41.tmp
- Deleting sa5a42.tmp
- Deleting sa5a53.tmp
- Deleting sa5ab1.tmp
- Skipping test.cmd

Done. 4 file(s) deleted.


C:\DATA\ZTEMP>ECHO From batch: 4 file(s) deleted.
From batch: 4 file(s) deleted.


Download

Command line application DeleteFilesOlderThan


Installation

None. Download the ZIP file, extract the included executable and run it.

Please note: this is a console application. You should run it from a command prompt.


Use case(s)


Syntax

DeleteFilesOlderThan /time=<time specification> /path=<folder to delete files from> [/filepattern=<files to delete>] [/subfolders=0|1] [/verbose=0|1] [/filessmallerthan=<size>|/filesgreaterthan=<size>] [/processpriority=i|b]

... or ...

DeleteFilesOlderThan /t=<time specification> /p=<folder to delete files from> [/f=<files to delete>[;<files to delete>]] [/s=0|1] [/v=0|1] [/fst=<size>|/fgt=<size>] [/pp=i|b]

Parameters:

Examples

DeleteFilesOlderThan /time=2d /path=D:\MyTarget

Delete all files from the folder D:\MyTarget which are older than two days.

DeleteFilesOlderThan /t=3w /p=C:\MyTarget\Data /f=*.txt /s=1

Delete all text files (*.txt) from the folder C:\MyTarget and all subfolders which are older than three weeks.


Source code

The PowerBASIC source code is available at Github


Known issues / limitations


Version

26.01.2021

Navigation

Tools

Info

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Germany License .
All contents copyright © 2012-2021 by BasicAware, Knuth Konrad