Create & Schedule File Deletion in Windows Environment

Share this article :

The activity is tested on Windows 7, Windows Server 2008 R2 and Windows Server 2012.

Step 1

1. Create a batch file using the notepad. Save the extension as .bat.

forfiles -p “[PATH_TO_THE_DESIRED_FILES]” -s -m *.* -d [NUMBERS_OF_DAYS] -c “cmd /c del @path”

Step 2

1. Open the Task Scheduler. Right click on the Task Scheduler (Local) > Create Basic Task.

Task Scheduler - Create Basic Task

2. Enter the name and description. Click Next.

Create Basic Task

3. Define the event periodic. Click Next.

Task Trigger

4. The screen below requires you to define the time / date. The selection below is based on Daily execution. If you choose Weekly, Monthly or others – it will be a different settings.


5. Choose Start a program. Click Next.

Action - Start a program

6. Locate the script you created earlier. Click Next.

Start a program

7. Click Finish.


Related posts

Find Windows System Up Time
Adjust Windows Command Prompt Screen Text & Background Colors
File Access Denied - require permission from S-1-1-0
Windows Server 2012: Installer UI Mode Error
© 2017 ITsiti. All Rights Reserved
Powered by KEEM