如何编写批处理文件以按时间删除文件夹和文件? [英] How do I write a batch file to delete folders and files on a time basis?
本文介绍了如何编写批处理文件以按时间删除文件夹和文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 如何编写批处理文件以从文件夹中删除5天或更早的文件?
- 编写批处理文件以从文件夹中删除6天以前的文件
- 编写批处理文件以从文件夹中删除5天或更旧的文件
- 如何创建一个批处理脚本,该脚本将按计划删除文件夹?
- 编写批处理文件以按日期和时间删除文件夹.
- 编写脚本以从比当前日期早5天的文件夹中删除文件
- How to write a batch file to delete the files which are 5 days or older from a folder?
- write a batch file to delete 6 days older files from a folder
- write a batch file to delete 5 daya older files from a folder
- How do I create a batch script that will delete a folder on a scheduled basis?
- write a batch file to remove the folders by date and time wise.
- write a script to delete files from a folder which are 5 days older than current date
我想编写一个批处理文件,以便及时删除文件夹,子文件夹和临时文件.
I want write a batch file to delete folders, subfolders and temporary files on time basis.
条件如下:
- 我需要在当前运行时间前一小时从文件夹中删除文件.
- 我想从系统获取当前时间并删除文件前一小时
- 文件格式如下:
<file name> <date>
- 时间格式为
dd-mm-yyyy-hh-mm
或dd-mm-yy-hh-mm
- I need to delete the file from folder one hour before to current running time.
- I want to get the current time from system and delete the one hour before files
- The file format is like this:
<file name> <date>
- The time format is
dd-mm-yyyy-hh-mm
ordd-mm-yy-hh-mm
推荐答案
批处理功能非常强大,但我认为您想要的日期操作不可行.
Batch can be surprisingly powerful but I don't think the kind of date manipulation you want will be practical.
您可以使用FOR
将日期拆分为元素,然后使用SET /A
进行减法,但是随后您将需要大量的IF
和GOTO
语句来处理类似从1月1日午夜半点开始减去一个小时.
You can use FOR
to split the date into elements and then use SET /A
to do the subtraction, but then you're going to need a huge number of IF
and GOTO
statements to handle cases like subtracting an hour from half past midnight on the 1st of January.
我认为您最好调查 VBS 或 Powershell .
这篇关于如何编写批处理文件以按时间删除文件夹和文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文