CMD next command traverses the directory and deletes the same file code _dos/bat

Source: Internet
Author: User
If you accidentally install some small tools to make rubbish, the same garbage files are generated under each letter in the system, as in my system there have been countless desktop_1.ini and Desktop_2.ini, At that time the first thought of the solution is to use Windows Search tool to find all the files, and then delete, this method is able to solve, but when the search do not forget to check the search hidden files and hidden folders, or you can not search for malicious manufacturing of garbage files.
Here's another easy way to do it, as long as you have a command that can do the same thing. It traverses the current letter and automatically deletes the found file.
Command format:
Copy Code code as follows:
I:\>for/f%i in (' dir desktop_1.ini desktop_2.ini/a/s/b ') do (attrib-r-s-h && del%i)

' dir desktop_1.ini desktop_2.ini/a/s/b ' can find all Desktop_1.ini and Desktop_2.ini, including hidden files, listed in full file path.
The for/f command analyzes the records in each row of the listed results,%i the record for each row is the full path to the file name here, and the following is the set of commands that handle the file name in parentheses, where you can see that the file is read-only, system, and hidden. This allows you to delete it with the Delete command Del.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.