Wishlist 0 ¥0.00

如何在 Windows 中自动删除文件

How to Automatically Delete Files in Windows

如何在 Windows 中自动删除文件

Create a batch file and then schedule it to run

创建一个批处理文件,然后安排它运行

Earlier I wrote about a program called DropIt that automatically moves or copies files for you when new files appear inside a folder. This can be useful, for example, if you have limited space on a local hard drive and want to move all your downloads off to an external storage device.

之前我写过一个叫做 DropIt 的程序,当新文件出现在文件夹中时,它会自动为你移动或复制文件。例如,如果您的本地硬盘空间有限,并希望将所有下载内容移动到外部存储设备,那么这可能会很有用。

If you want to automatically delete files, there are two ways you can go about it in Windows. The first method involves downloading a freeware app called AutoDelete that lets you configure a schedule for deleting files in a particular folder. I’ve already written two detailed guides on using the program , so check those out if you prefer a freeware program to get the job done.

如果你想自动删除文件,在 Windows 中有两种方法。第一种方法包括下载一个名为 AutoDelete 的免费软件应用程序,该应用程序允许您配置删除特定文件夹中的文件的时间表。我已经写了两篇关于如何使用这个程序的详细指南 ,所以如果你更喜欢免费软件程序来完成这项工作,请查看这些指南。

The second method for deleting files is to create a batch file and then schedule that batch file to run. You can do all of that without installing any third-party software. In this article, I’ll walk you through the steps for creating a batch file and then using Task Scheduler to have the script run on a reoccurring basis.

删除文件的第二种方法是创建一个批处理文件,然后安排该批处理文件运行。你可以在不安装任何第三方软件的情况下完成所有这些操作。在本文中,我将指导您完成创建批处理文件的步骤,然后使用 Task Scheduler 在重复的基础上运行脚本。

Step 1 – Create Batch File

步骤1-创建批处理文件

If creating a batch file sounds a bit scary or too technical, don’t worry because you don’t have to know what any of that means. I’ll explain what you need to copy and paste, where and what options you can change. First, open Notepad and copy and paste the following line of text:

如果创建一个批处理文件听起来有点吓人或者太技术化,不要担心,因为你不需要知道这些意味着什么。我将解释您需要复制和粘贴哪些内容,以及您可以更改哪些选项。首先,打开记事本,复制粘贴下面的文本行:

forfiles -p "C:\Test" -s -m *.* /D -5 /C "cmd /c del @path"

The line above probably makes no sense, which is perfectly fine as I’ll explain it down below. Basically, it tells Windows to delete all files in the C:\Test folder and sub-folders that are older than 5 days. Here is what your Notepad file should look like.

上面的这条线可能没有任何意义,这是非常好的,因为我将在下面解释它。基本上,它告诉 Windows 删除 c: Test 文件夹和超过5天的子文件夹中的所有文件。下面是你的记事本文件应该是的样子。

notepad delete files

 

Before we get into more details about the command, let’s save the file and give it a test run. First, create a folder on your computer called Test at the root of the C drive. Next, click FileSave and save the file as a batch file. To do that, type in a name followed by .bat and then change the Save as type dropdown to All Files.

在了解更多关于该命令的细节之前,让我们先保存该文件并对其进行测试运行。首先,在 c 驱动器的根目录下创建一个名为 Test 的文件夹。接下来,单击 File-Save 并将文件保存为批处理文件。要做到这一点,输入一个名称后面跟着。然后更改保存类型下拉到所有文件。

save as batch file

Note that you can save the file to whichever location on the hard drive you like, it doesn’t really matter. Now create some dummy files in the Test folder and then double click on the Delete.bat file to run it. Anything get deleted? Probably not!

请注意,您可以将文件保存到硬盘驱动器上您喜欢的任何位置,这并不重要。现在在 Test 文件夹中创建一些虚拟文件,然后双击 Delete.bat 文件运行它。有什么被删除了吗?可能不会!

The reason why nothing was deleted is because the command has /D -5, which means files that are 5 days or older. In order to delete any file regardless of when it was created, you can either change the -5 to -0 or you can remove the /D -5 part altogether. Now if you run it, all the files will be deleted.

之所以没有删除任何内容,是因为命令具有/d-5,这意味着文件已经超过5天。为了删除任何文件,不管它是什么时候创建的,您可以将 -5修改为 -0或者完全删除/d-5部分。现在,如果你运行它,所有的文件将被删除。

To customize the command, the first thing you can do is change the directory to something other than C:\Test. That’s as simple as copying the path from Windows Explorer for the directory you want and pasting it into the command in Notepad.

要自定义命令,首先要做的是将目录更改为 c: Test 以外的其他目录。这很简单,只需将路径从文件资源管理器文件中复制到你想要的目录,然后粘贴到记事本中的命令中。

copy path explorer

Next is the -s parameter that you see after the directory path. This indicates that the command should look into all sub-folders also. If you do not want to delete files from subfolders, go ahead and remove the -s parameter.

接下来是您在目录路径之后看到的-s 参数。这表示命令还应该查看所有子文件夹。如果不想从子文件夹中删除文件,请继续删除-s 参数。

Next is -m followed by *.*, which means that the command should evaluate files of every kind. If you only want to delete a specific file type in a folder, like PDF files or JPG images, just change *.* to *.pdf or *.jpeg and it will only remove those files.

下一个是-m,接着是 * 。* ,这意味着命令应该评估各种文件。如果您只想删除文件夹中的某个特定文件类型,比如 PDF 文件或 JPG 图像,只需更改 * 。* to * .Pdf 或 * 。它只会删除那些文件。

The /D -X part we already talked about in terms of how old the files have to be in order to qualify for deletion. You can either keep it with a value greater than 1, set it to 0, or remove it altogether. That’s about all we need to know about the command.

我们已经讨论过的/d-x 部分涉及文件的年龄以便有资格被删除。您可以将其保持为大于1的值,也可以将其设置为0,或者将其完全删除。这就是我们需要知道的关于指挥部的一切。

There are a few things to note about running this command. Firstly, when files are deleted, they do not go to the Recycle Bin, but instead are deleted permanently, so be careful when using it. Secondly, the command only deletes files, not folders.

关于运行这个命令,需要注意一些事项。首先,当文件被删除时,它们不会进入回收站,而是被永久删除,所以使用时要小心。其次,该命令只删除文件,而不删除文件夹。

Since this is a batch file, you could also add multiples versions of this command in the same file. For example, here I am creating a batch file that will delete all DOCX files older than 180 days, all PDF files older than 60 days and all TXT files regardless of how old the files are.

由于这是一个批处理文件,您还可以在同一文件中添加该命令的多个版本。例如,这里我正在创建一个批处理文件,它将删除所有超过180天的 DOCX 文件,所有超过60天的 PDF 文件和所有 TXT 文件,不管这些文件有多老。

batch file delete

Step 2 – Schedule Batch File

第二步-安排批处理档案

Now that you have your batch file created and saved, let’s go ahead and schedule it to run on a reoccurring basis. To do this, we have to open up Task Scheduler.

现在您已经创建并保存了批处理文件,接下来让我们继续安排它在重复出现的基础上运行。要做到这一点,我们必须打开任务计划程序。

Luckily, I’ve already written an article on how to schedule a batch file, so open that page to get started. Scroll down to the Schedule Batch File on PC Startup section and follow along.

幸运的是,我已经写了一篇关于如何安排批处理文件的文章,所以打开那个页面开始吧。向下滚动到 PC 启动部分的计划批处理文件,然后跟随。

Task-Trigger.png

The only thing you have to change is the Trigger. You can choose from Daily, Weekly, Monthly, When the computer starts, When I log on or When a specific event is logged.

你唯一需要改变的就是触发器。您可以从“每日”、“每周”、“每月”、“计算机启动时间”、“登录时间”或“记录特定事件时间”中进行选择。

When you pick something like Weekly or Monthly and click Next, you’ll get a new screen where you can configure the exact time and days you want the script to run.

当您选择诸如周或月之类的内容,然后单击 Next,您将得到一个新的屏幕,您可以在其中配置希望脚本运行的确切时间和天数。

weekly schedule

mothly schedule

Hopefully, this is a good solution for most people who need to perform some simple automated tasks for deleting files on their PCs. If you have any questions, feel free to post a comment. Enjoy!

希望这是一个很好的解决方案,为大多数人谁需要执行一些简单的自动化任务删除文件在他们的电脑上。如果你有任何问题,请随时发表评论。享受吧!

如何在 Windows 中自动删除文件夹中的所有文件

How to Automatically Delete All Files in a Folder in Windows

如何在 Windows 中自动删除文件夹中的所有文件

To clean up a folder on a regular basis, you can configure Windows to automatically delete all files and folders in a folder. Here’s how.

若要定期清理文件夹,可以将 Windows 配置为自动删除文件夹中的所有文件和文件夹。以下是如何做到这一点。

In Windows, deleting files in a folder is as easy as selecting all of them and then pressing the DELETE key. However, if you want to automatically delete all files in a folder then the story will be different. You have to go through some hoops to get the job done.

在 Windows 中,删除文件夹中的文件只需选择所有文件,然后按 DELETE 键即可。但是,如果您想自动删除一个文件夹中的所有文件,那么故事将是不同的。你必须经过一些程序才能完成这项工作。

 

Recently, I received an email from a WL user asking me a way to automatically delete all the files and folders in a folder on schedule. Coincidentally, I’ve been doing that for many years now with my Screenshots folder. To be more precise, I sync my Screenshots folder with OneDrive and configured Windows Task Scheduler to delete all files in the Screenshot folder as soon as I log into the system. Since all the files are already synced with OneDrive, there is no data loss. It just cleans the clutter. You can do that same with any folder you want.

最近,我收到一封来自 WL 用户的邮件,问我如何按时自动删除文件夹中的所有文件和文件夹。巧合的是,我已经用我的截图文件夹做了很多年了。更准确地说,我用 OneDrive 同步了我的 Screenshots 文件夹,并配置了 Windows 任务调度程序,一旦我登录到系统,就删除了 Screenshot 文件夹中的所有文件。因为所有的文件都已经与 OneDrive 同步,所以没有数据丢失。它只是清理杂物。你可以对任何你想要的文件夹做同样的事情。

So, without further ado, let me show the way you can automatically delete all files in a folder on schedule in Windows.

所以,废话少说,让我来演示一下如何在 Windows 中按计划自动删除一个文件夹中的所有文件。

Note: I’m showing this in Windows 10 but you can follow the same steps in Windows 7 and 8. Also, don’t confuse the below method with Storage Sense feature in Windows 10. Storage Sense will only clean/delete files in system folders like Downloads, temp, etc. You cannot assign custom folders to it.

注意: 我在 Windows 10中展示了这一点,但是你可以在 Windows 7和8中遵循同样的步骤。另外,不要将下面的方法与 Windows 10中的存储感知功能混淆。Storage Sense 只会清理/删除系统文件夹中的文件,比如下载文件、临时文件等。不能为其分配自定义文件夹。

Delete All Files Automatically in a Folder

自动删除文件夹中的所有文件

Since Windows has no simple way to automatically delete all files and folders in a folder, you need to create a batch script to get the job done. After creating that, you can use the task scheduler to execute the batch script on a schedule.

由于 Windows 没有简单的方法自动删除文件夹中的所有文件和文件夹,因此需要创建一个批处理脚本来完成这项工作。创建该脚本之后,您可以使用任务调度程序在调度表上执行批处理脚本。

 

1. The first thing we need to do is create a batch script aka, .bat file. To do that, right-click on the desktop and select “New → Text Document“.

1.我们需要做的第一件事是创建一个批处理脚本,也就是,。蝙蝠锉。要做到这一点,右键单击桌面并选择“新建→文本文档”。

2. This action will create a new text file. Name the text file as “AutoDelete.bat“. You can name the file anything you want. Just make sure that you replace .txt extension with .bat.

图2。此操作将创建一个新的文本文件。将文本文件命名为“ AutoDelete.bat”。你可以给文件起任何名字。只要确保你能够用.bat替换掉.txt。

 

3. After creating the .bat file, right-click on it and select the “Edit” option. This option will open the file in your default text editor, Notepad. In the Notepad, copy and paste the below code. Replace the dummy path with the actual folder path.

图3。在创建了。在 bat 文件中,右键单击它并选择“ Edit”选项。此选项将在默认文本编辑器“记事本”中打开该文件。在记事本中,复制并粘贴下面的代码。用实际的文件夹路径替换虚拟路径。

set folder="D:\replace\dummy\folder\path"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
Delete-all-files-in-a-folder-paste-code

4. Save the file by pressing the Ctrl + S keyboard shortcut or by selecting the “File → Save” option. After saving, close the file.

图4。通过按 Ctrl + s/快捷键或选择“文件→保存”选项来保存文件。保存之后,关闭文件。

5. After creating the file, use the Task Scheduler to schedule the batch file. I’ve already written a detailed step by step guide on how to do it. Do follow the article and you will be done.

5.创建文件后,使用“任务计划程序”调度批处理文件。我已经写了一个详细的一步一步的指导如何做到这一点。照着这篇文章做,你就会完成。

In case you are wondering, all the files and folders deleted from the target folder will still be available in the Recycle Bin. This makes it easy to restore them if need be.

如果您想知道的话,从目标文件夹中删除的所有文件和文件夹在回收站中仍然可用。这使得在需要的时候恢复它们变得容易。

I hope that helps. If you are stuck or need some help, comment below and I will try to help as much as possible.

我希望这能有所帮助。如果你遇到困难或者需要帮助,请在下面评论,我会尽可能的帮助你。

终极 Excel 公式备忘单:50 个最重要的公式

Microsoft Excel 对任何人来说都很容易上手。 但是许多高级功能也隐藏在引擎盖下。

大多数人可以立即在 Excel 中执行基本功能。 但是,要想在 Excel 中完成更复杂的工作,首先需要您知道可用的内容。

通过阅读此备忘单,您将了解有关 Excel 可以为您做什么的更多信息。

Excel 快捷方式和命令

除了需要了解 Excel 的核心功能之外,您可能还想了解更多关于快捷方式的知识。 快捷方式和命令使在 Excel 中执行基本操作变得更加容易,因为您无需搜索菜单。 仅按 CTRL + D 比手动复制和粘贴更容易。

以下是一些最流行的快捷方式:

功能 捷径
插入当前日期 Ctrl+;
插入当前时间 移位+Ctrl+;
编辑单元格注释 狗屎+F2
显示活动单元格 ctrl+退格
插入列 alt + lC
插入行 alt + lR
填写 Ctrl+D
向右填充 Ctrl+R
自动求和 Alt + =
插入图表 Alt + F1
保存工作簿 Shift+Alt+F2
移到最后 Ctrl+END

 

Excel 单元格参考备忘单

 

Excel 中的大多数公式都需要单元格引用。 如何定义单元格引用将影响公式的应用和从一个复制到另一个的方式。 以下是在 Excel 中引用单元格的最常用方法列表。

相对单元格参考 =A2+B2
绝对单元格参考 +$A$1

相对单元格参考

相对单元格引用是指特定单元格的地址,当您将公式从一个单元格复制到下一个单元格时,该单元格引用会自动调整。 相对单元格引用由单元格的地址组成。

如果使用相对引用,当您将公式 +A1+B1 复制到另一个单元格时,Excel 会自动更改公式以反映新的列号或行号,例如 +A2+B2。

绝对单元格引用

要在复制公式时阻止 Excel 更改行或列引用,可以在公式中使用绝对单元格引用而不是相对引用。 要创建绝对单元格引用,您需要在单元格引用中插入“$”符号以指示不应调整该值。

Excel 日期和时间函数

今天是什么日子? 你必须看看日历。 但是你的电脑已经知道了。 Excel 具有许多嵌入式日期和时间函数,可以让您的生活更轻松。

注意:在内部,Excel 使用“序列号”来表示日期。 因此,Excel 的函数通常返回一个序列号日期——还有其他函数用于将其格式化为可读版本。

功能 句法 描述
日期 DATE(年、月、日) Excel 日期函数在给定年、月、日参数的情况下返回日期。
日期 DATEDIF(开始日期,结束日期,单位) 此函数计算两个给定日期之间的时间。
DAY(序列号) 此函数以 1 到 31 之间的整数形式返回日期的实际日期。
教育日期 EDATE(开始日期,月) 此函数在开始日期上添加几个月。
一个月 EOMONTH(开始日期,月) 此函数与 EDATE 函数执行相同的操作,但它返回该月的最后一个期间。
现在 现在() now 函数返回表示当前时间(包括小时)日期的序列号。
今天 今天() today 函数返回代表日期的序列号(只是日期)。
年() year 函数将表示日期的序列号转换为年份。

抄送与密件抄送: 这两个电子邮件字段的区别是什么?

CC vs. BCC: What’s the Difference Between These Two Email Fields?

抄送与密件抄送: 这两个电子邮件字段的区别是什么?

When referring to email, “cc” means carbon copy and “bcc” means “blind carbon copy”.  Both “cc” and “bcc” are additional fields you can enter when sending an email.  

当提到电子邮件时,“抄送”意味着复写,“密件抄送”意味着“盲复写”。“抄送”和“密件抄送”都是发送电子邮件时可以输入的附加字段。

Every recipient email address you enter into the “to” and “cc” fields will be able to see each other.  The email addresses you add to the “bcc” field will not be visible to the “to” and “cc” recipients or the other “bcc” recipients.

每个收件人的电子邮件地址,你输入“到”和“抄送”字段将能够看到彼此。您添加到“密件抄送”字段中的电子邮件地址对“收件人”和“密件抄送”收件人或其他“密件抄送”收件人不可见。

Addressing an email

邮件地址

When you send an email, you have three field choices: “to”, “cc”, and “bcc”.  Here is how to use each field:

当您发送电子邮件时,您有三个字段选择: “到”、“抄送”和“密件抄送”。下面是如何使用每个字段:

  • To: enter the email addresses of the people the email is targeted to
  • 要: 输入电子邮件目标人群的电子邮件地址
  • Cc: enter the email addresses of the people you want to know about the email (remember that everyone will see their names)
  • 抄送: 输入你想了解的人的电子邮件地址(记住,每个人都会看到他们的名字)
  • Bcc: enter the email addresses of the people you want to know about the email but not announce to everyone else that they are getting a copy
  • 密件传送: 输入你想知道的人的电子邮件地址,但不要告诉其他人他们正在得到一个副本

Why would you “cc” someone on an email?

你为什么要在电子邮件上“抄送”某人?

Carbon copying someone on an email is a great way to keep them in “the loop” and allows them to know what is going on without actually being involved.  It can be a useful way to remind people of what happened at a meeting or to remind them to take action on something.  Carbon copying also makes the recipient aware of who else is looking at the email. This is often used in business settings to get the primary recipient (the “to” field) of the email to take the message more seriously or to let them know that it is important. 

在电子邮件上抄袭别人的邮件是一个很好的方法,让他们保持“循环”,并让他们知道正在发生什么,而实际上没有参与。它可以是一个有用的方式来提醒人们在会议上发生了什么,或者提醒他们对某事采取行动。碳复制还可以让收件人知道还有谁在看电子邮件。这通常用于业务设置,以获得电子邮件的主要收件人(“到”字段)更认真地对待邮件或让他们知道这是重要的。

Person typing on laptop keyboard

Why would you “bcc” someone on an email?

你为什么要在电子邮件上“密件”某人?

Blind carbon copying someone to an email is common when you want to keep the recipients’ privacy.  One example is to use BCC when emailing a long list of people who do not know each other like in a mailing list.  Another reason to blind carbon copy someone is to keep them in the loop of a conversation without letting the other recipients (the “to” and “cc” fields) know.  In business, this can be used to tattle on someone by blind carbon copying your superiors on an email thread.  Blind carbon copying also prevents the recipients listed in the “bcc” field from receiving any  “reply all” emails.

当你想保护收件人的隐私时,盲目抄袭别人的电子邮件是很常见的。一个例子是使用 BCC 发送邮件给一长串互不认识的人,就像邮件列表一样。另一个不让别人知道的原因是让他们参与谈话,而不让其他收件人(“ to”和“ cc”字段)知道。在生意场上,这可以被用来通过电子邮件盲目复制你的上司来告发某人。盲复写还可以防止“密件抄送”字段中列出的收件人收到任何“全部回复”的电子邮件。

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.