Remove All Files That Are Older Than
Share
The following bat file will delete all files in a directory and its subdirectories that are have a modified date older than 2 years:
@ECHO OFF REM *** DELETE FILES OLDER THAN 2 YEARS REM *** GET TODAYS DATE @For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @( Set Month=%%A Set Day=%%B Set Year=%%C ) REM @echo DAY = %Day% REM @echo Month = %Month% REM @echo Year = %Year% REM *** SUBTRACT 2 FROM THE CURRENT YEAR set /a Year2=%Year%-2 forfiles /p "E:\IIS6LOGFILES" /s /m *.log /d -%Month%/%Day%/%Year2% /c "cmd /c del @path"
Author
Stewart Schatz
More Stories
How to Clean Up Empty Directories Using the find Command in Linux
Managing files and directories in Linux often involves dealing with empty directories that can clutter your workspace. Manually finding and...
How to Print a Directory Structure Using PowerShell: Step-by-Step Guide
If you need to print out the directory structure and list the files within, this PowerShell script will help you...
VirtualBox Fails After Windows 11 Upgrade (NtCreateFile failed)
After upgrading from Windows 10 to Windows 11, VirtualBox fails to start your Virtual Machine. You receive this error: NtCreateFile...
Quick Tip: WebLogic NodeManager Fails To Start As Windows Service
If your Oracle WebLogic NodeManager starts without issue when using startNodeManager.cmd but when configuring the WebLogic NodeManager as a Windows Service, it fails to start. The nodemanager.log file has the following entry: Native version is enabled but NodeManager native library could not be loaded
Quick Tip: Determine Active Directory Account Status From The Windows Commandline
Use the following command to Determine Active Directory Account Status from the Windows Commandline without Powershell or any special software....
Where Is Java Installed?
Below are a few commands that can be run to determine where Java is installed on each Operating System: Windows:...
Average Rating