- Knowledge Base
- Installation and System Setup
- Installation
-
News
-
Roadmap
-
Installation and System Setup
-
Setup Data Catalog
-
Connectors
-
Data Discovery
-
Self Service
-
Access Management
-
Data Quality
-
Data Literacy
-
Privacy Compliance
-
Reporting
-
Architecture, Security & Releases
-
Developer's Zone
-
Advanced Tools
-
Record of Processing Activities (ROPA)
-
Data Catalog
-
Release6.0 User Guide
-
Release6.1 Deep Dive Articles
-
Release6.1.1 Deep Dive Articles
-
Release6.2 Deep Dive Articles
-
Release6.3 Deep Dive Articles
-
Deactivated_Old
Auto Delete Old Files with Task Scheduler
This article explains how to create a Windows Task Scheduler job that deletes files older than 10 days at a scheduled time.
Prerequisites
- Administrator access to the OvalEdge Application Virtual Machine (VM).
Steps to Set Up File Deletion
-
Create a Batch Script
- Connect to the Windows server.
- Create a .bat file in any folder and paste the following code:
@echo off
set "directory=C:\tomcat\apache-tomcat-9.0.102-windows-x64\apache-tomcat-9.0.102\logs"
set "days=10"
echo Deleting files older than %days% days from: %directory%
forfiles /p "%directory%" /s /m * /d -%days% /c "cmd /c if @isdir==FALSE del /q @path"
echo Cleanup completed. - Update the directory and day values as needed.
C:\tomcat\apache-tomcat-9.0.102-windows-x64\apache-tomcat-9.0.102\logs is the logs files path
days=10 means it will delete the last 10 days files (you can change as per requirement)
- Test the Script Manually
- Open Command Prompt.
- Go to the folder where the .bat script is saved.
- Run the script by typing:
-
delete.bat - Check the folder before and after running the script to confirm that it deletes files older than 10 days.
- Before executing the script,
- Bat script execution
- After executing the script
- If files are deleted as expected, the script will work correctly.
- Create the Task in the Task Scheduler
- Open Task Scheduler from the Windows search bar.
- Click Create Basic Task.
- Enter a name and click Next.
- Add the trigger and select the Daily option to perform the task daily.
- Choose Daily and set the time you want the task to run.
- Under Action, select Start a Program.
- Browse and select your .bat file.
- Click Next, check the summary, and click Finish.
- Enable all necessary checkboxes and click OK.
- Click OK to view the scheduled task.
- It will now delete files from the set location at the scheduled time.
Conclusion
By following the steps in this document, you can automate the deletion of files older than 10 days using Windows Task Scheduler. This helps keep your system clean and saves storage space without manual effort.