Home > Operation and Maintenance > Windows Operation and Maintenance > Use Windows scheduled tasks to delete files in the specified directory

Use Windows scheduled tasks to delete files in the specified directory

王林
Release: 2021-02-07 09:38:36
forward
4271 people have browsed it

Use Windows scheduled tasks to delete files in the specified directory

We have two ways to delete files in the specified directory, one is to use the Windows scheduled task or to call the bat file through the Windows scheduled task.

Let’s explain it in detail below.

1. First create a new bat file:

bat file description:
forfiles automatically deletes files 7 days ago (based on the current system time)
Example:
Code Code example:
forfiles /p “d:\test” /s /m . /d -7 /c “cmd /c del @path”
replace d:\test with the directory path you want;
/d -7 means to delete files older than 7 days.

Use Windows scheduled tasks to delete files in the specified directory

#2. Set up windows scheduled tasks and bind the bat file.
Search windows-task scheduler

Use Windows scheduled tasks to delete files in the specified directory

Create task
You need to click the task scheduler library or the menu below the task scheduler library to create a new task.

Use Windows scheduled tasks to delete files in the specified directory

Set tasks
Fill in the task name-Set security options

Use Windows scheduled tasks to delete files in the specified directory

Set triggers as required by the business -Run frequency

Use Windows scheduled tasks to delete files in the specified directory

Click operation-New-Browse-Select the new bat file-Confirm

Use Windows scheduled tasks to delete files in the specified directory

Click to confirm- You can see the scheduled task you just set in the task list.
Clicking the right button can also run, end and other functions. Is not it simple.

Use Windows scheduled tasks to delete files in the specified directory

Related recommendations: windows system

The above is the detailed content of Use Windows scheduled tasks to delete files in the specified directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template