In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how windows to achieve the batch operation of deleting files, I hope you will gain something after reading this article, let's discuss it together!
1. Delete the 7-day extension bkf file under the current directory with a batch file (based on the current system time)
Example: forfiles / m * .bkf / d-7 / c "cmd / c del @ file / f"
2. Forfiles automatically deletes files 7 days ago (based on current system time)
Example: forfiles / p "d:/test" / s / m *. * / d-7 / c "cmd / c del @ path"
Change d:/test to the directory path you want; / d-7 means to delete files 7 days ago.
3. Delete all empty directories (take deleting the d:/test directory as an example):
Dir / ad/b/s d:/test/ | sort / r > d:/kill.txt
For / f "tokens=*" I in (d:/kill.txt) DO rd "I"
Del d:/kill.txt
4. Delete the files 7 days ago, and then delete all empty directories; copy the following to the bat file.
@ echo off
Forfiles / p "d:/test" / s / m *. * / d-7 / c "cmd / c del @ path"
Dir / ad/b/s d:/test/ | sort / r > d:/kill.txt
For / f "tokens=*" I in (d:/kill.txt) DO rd "I"
Del d:/kill.txt
5. Usage and parameters of forfiles command:
Forfiles / p / d / c
/ p specifies the directory in which to look for files, and the default is the current working directory.
/ d specify a date or number of days to compare whether the last modified date of the file meets the criteria.
/ c the command executed for each file found.
Example 1. To copy files in the C root directory with a last modification date greater than or equal to January 7, 2010 to the D root directory:
Forfiles / p "forfiles /" / d "2007-7-1" / c "cmd / c copy @ path DVR /"
Example 2. Delete the files under the backup directory of disk C that were last modified 10 days ago:
Forfiles / p "c:/backup" / d-10 / c "cmd / c echo deleting @ file... & & del / f @ path"
6. Forfiles / p contains the full path of the file to be deleted (e.g. F:/Logfiles) / m * .log-d-7 / c "cmd / c del / f
@ path "
Explain the relevant parameters and commands
/ p: specify the location where to start the search for files, or the current directory by default if not specified.
/ m: the wildcard characters used in file lookup, such as "* .log" in the code, are all log files, of course, you can also specify
All log files starting with manmee, such as "manmee_*.log". If you do not specify this parameter, it defaults to "*. *".
/ d [{+ | -}] [{|}]: specify the last modification time of the file you want to select. "/ d-7" is used above to indicate all
Days-based, 7-day-old files. Of course, you can also specify a specific time here, for example: "/ d-01swap 7Universe 2010" so that all earlier than 2010
The document of January 7th. Note that the specified time must be in the format "MM/DD/YYYY".
/ c execute the specified command on all files in double quotation marks ("). The default is" cmd / c echo @ file ". Used above
To "cmd / c del / f @ path" to delete the specified file. (@ file and @ path here are variables, which are explained below. )
Let's talk about the parameters used above:
PATH: represents the full path to the file.
File: indicates the name of the file.
After reading this article, I believe you have a certain understanding of "how windows realizes the batch operation of deleting files". If you want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.