Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Windows automatically clears expired files in a specific directory

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

There is a shared directory in the unit Windows server for file transfer, but it needs to be cleaned regularly, so I came up with the method of Windows scheduling tasks + batch scripts. The specific functions are as follows:

Batch script: automatically delete files and folders created 8 days ago Windows schedule task: automatically run script 1. 0 at 06:00 every week. Implementation of batch script

The script for batch processing is regular_clean.bat:

@ echo offforfiles / p "C:\ inetpub\ ftproot" / s / m *. * / d-8 / c "cmd / c del @ path" for / f "delims="% an in ('dir / b / ad / s "C:\ inetpub\ ftproot" ^ | sort / r') do rd / Q "% a" 2 > null

Description:

1.forfiles is the search destination directory, where C:\ inetpub\ ftproot; searches for., all files; the expiration time is 8 days (/ d-8).

two。 The final for is the process of specifically finding subdirectories.

Implementation of 2.Windows Planning Task

Click: start-> Administrative tools-> Task Scheduler-> create a task, and select the desired options according to the window prompts.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report