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

The System Administrator has set policies to prevent this installation
Adjust / Change Windows Command Prompt Font & Size
Enable & Disable Windows Taskbar Button Combine
Increase / Decrease Number of Recent Items & Program Display
© 2017 ITsiti. All Rights Reserved
Powered by KEEM