Hướng dẫn sử dụng ForFiles để xóa các tệp cũ hơn N ngày trên Windows 10
Hướng dẫn sử dụng ForFiles để xóa các tệp cũ hơn N ngày trên Windows 10
Cách 1: Sử dụng ForFiles để xóa các tệp cũ hơn N ngày trên Windows 10:
- Mở CMD với quyền admin
- Gõ lệnh: ForFiles / p "C: \ path1\path2\pathN" / s / d -10 / c "cmd / c del @file"
- / p - cho biết tên đường dẫn để bắt đầu tìm kiếm.
- / s - hướng dẫn ForFiles tìm kiếm bên trong các thư mục con.
- / d - chỉ định ngày sửa đổi cuối cùng cho một tệp.
- / c - hướng dẫn ForFiles thực thi lệnh, cần được gói trong dấu ngoặc kép, mặc định là mật mã cmd / c del @file .
Cách 2: Sử dụng Task Scheduler để tự động xóa các tệp cũ hơn N ngày trên Windows 10
- pen Start.
- Search for Task Scheduler and click the top result to open the experience.
- Right-click the Task Scheduler Library folder.
- Click the New Folder option.
- Type any name for the folder and click OK. (We’re creating a new folder to keep tasks organized and separated from the system tasks.)
- Right-click the recently created folder, and select the Create Task option.
- In the “Name” box, enter a name for the task.
- In the “General” tab, under the “Security options” section, select the Run whether user is logged on or not option. (This is the option that will make the command window not to appear when the task runs automatically.)
- Thẻ lập lịch tác vụ
- Task Scheduler General tab
- Clear the Do not store password option.
- Click the “Triggers” tab, and click the New button.
- Using the “Begin the task” drop-down menu, select the On a schedule option.
- Under “Settings,” specify when you want the task to run (e.g., On time, Daily, Weekly, Monthly). Whatever option you select, make sure to specify the Start settings on the right side.
- Click the OK button.
- Cài đặt trình lập lịch tác vụ
- Task Scheduler Trigger settings
- Click the “Actions” tab, and click the New Button.
- Using the “Actions” drop-down menu, select the Start a program option.
- In the “Program/script” box, type the following command:
- ForFiles
- In the “Add arguments” box, type the following command and click the OK button.
- /p "C:\path\to\folder" /s /d -30 /c "cmd /c del @file"
- In the above command remember to change "C:\path\to\folder" specifying the path to the folder that you want to delete files, and change /d -30 to select files with a last modified date.
- Lập lịch tác vụ Cài đặt hành động
- Task Scheduler Action settings
- Click the “Settings” tab, and make sure to check the following options:
- Allow task to be run on demand.
- Run task as soon as possible after a scheduled start missed.
- If the task fails, restart every.
- Click the OK button.
- Task Scheduler additional settings
- If prompted, enter your administrative username and password.
- Click the OK button.
Post a Comment
Post a Comment