如何按计划自动删除下载文件夹中的文件

Delete 0

Whether you share your computer with other people or you use it for a lot of downloads, it is nice to be able to clear out the download folder without having to manually take care of it each week or month, which is when an automated deletion comes in handy.

无论您是与他人共享计算机还是要进行大量下载,都可以清除下载文件夹,而不必每周或每月手动进行处理,这是很好的选择,这是在自动删除功能出现时派上用场。

You can automate the cleanup of your download folder using a batch file that will delete files older than a certain amount of days. You can run this whenever you feel that you need to clean up your download folder or you can use the Task Scheduler to run it daily, weekly, monthly, etc.

您可以使用批处理文件自动清理下载文件夹,该批处理文件将删除超过一定天数的文件。 您可以在需要清理下载文件夹时运行它,也可以使用任务计划程序每天,每周,每月等运行它。

创建您的批处理文件 (Create Your Batch File)

For this example, we will tell the batch file to delete any files that are located in the download folder that are older than 30 days. This is useful if you do things like Photoshop work, or writing where you download a lot of resources that you don’t need after an extended period of time.

对于此示例,我们将告诉批处理文件删除下载文件夹中超过30天的所有文件。 如果您执行诸如Photoshop工作之类的事情,或者在较长的一段时间内编写下载大量不需要的资源的位置时,此功能将非常有用。

The first step will be to open notepad. Once you have the program open, paste this string into the screen.

第一步将打开记事本。 打开程序后,将此字符串粘贴到屏幕中。

REM Remove files older than 30 days
forfiles /p "C:\Users\YOURUSERNAME\Downloads" /s /m *.* /c "cmd /c Del @path" /d -30
REM Remove files older than 30 days
forfiles /p "C:\Users\YOURUSERNAME\Downloads" /s /m *.* /c "cmd /c Del @path" /d -30
射击1

Remember to change the directory to match your computer. You can also choose any directory that is on your computer for the target. Once you have entered the string, save the document as a batch file.

切记更改目录以匹配您的计算机。 您也可以为目标选择计算机上的任何目录。 输入字符串后,将文档另存为批处理文件。

射击2

Simply run the file to make sure it works and you will see that any files in your download folder are automatically sent to your Recycle Bin if they are older than 30 days.

只需运行文件以确保其工作,并且如果超过30天,下载文件夹中的任何文件都会自动发送到回收站。

创建计划任务 (Create a Scheduled Task)

For the purpose of this example, we will schedule the automatic file deletion every seven days. Begin by opening the start menu and typing in “Task Scheduler” then running the application.

就本示例而言,我们将每7天安排一次自动文件删除。 首先打开开始菜单,然后输入“ Task Scheduler ”,然后运行该应用程序。

Alternatively, you can open your “Control Panel.” Under the “System and Security” section select the “Administrative Tools” option and then run the “Task Scheduler.”

或者,您可以打开“控制面板”。 在“系统和安全性”部分下,选择“管理工具”选项,然后运行“任务计划程序”。

Once you have the program open, click on the “Action” drop-down menu and select “Create Basic Task.”

打开程序后,单击“操作”下拉菜单,然后选择“创建基本任务”。

射击3

You can give the task a name and description of your choosing. For this example, we will call it “Weekly Download Cleanup” and leave the description empty since the title is self-explanatory; then click “Next.”

您可以为任务选择名称和描述。 在此示例中,我们将其称为“每周下载清理”,并将描述保留为空,因为标题是不言自明的。 然后点击“下一步”。

射击4

From the “Trigger” section, we will choose to make the task a weekly action followed by pressing “Next.”

在“触发器”部分,我们将选择每周执行一次任务,然后按“下一步”。

射击5

Now you will need to select a time and day. Remember to choose a time and day that your computer is powered on. For this example, we will just choose midnight on Friday then click next.

现在,您将需要选择时间和日期。 切记选择打开计算机电源的时间和日期。 对于此示例,我们只选择星期五的午夜,然后单击下一步。

射击6

Now you will see the “Action” screen. We will leave this as is, since we want to run a specific program every Friday; so you can just click “Next.”

现在,您将看到“操作”屏幕。 因为我们要在每个星期五运行一个特定的程序,所以我们将其保持不变。 因此您只需单击“下一步”。

射击7

Now you will just need to click on “Browse” and select the batch file you created. As you can see, our batch file was saved on the desktop and is called “DownloadCleanup.bat.” Once you have done that, just click “Next.”

现在,您只需要单击“浏览”并选择您创建的批处理文件。 如您所见,我们的批处理文件保存在桌面上,称为“ DownloadCleanup.bat”。 完成此操作后,只需单击“下一步”。

射击8

The last screen you will see gives you a comprehensive overview of the task you created. Once you verify that everything is right, just click “Finish” to complete the task creation and it will run automatically according to your specifications.

您将看到的最后一个屏幕为您提供了所创建任务的全面概述。 确认一切正确后,只需单击“完成”以完成任务创建,它将根据您的要求自动运行。

射击9

Now that you know how to schedule auto-deletion of your old files, you don’t need to worry about how to clear up any old files from your download folder.

现在,您知道如何安排自动删除旧文件了,您无需担心如何从下载文件夹中清除所有旧文件。

Image Credit: Mixy Lorenzo on Flickr

图片来源: Flickr上的Mixy Lorenzo

翻译自: https://www.howtogeek.com/201930/how-to-automatically-delete-files-in-your-download-folder-on-a-schedule/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值