Hongmu Notes
Home Summary of pitfalls Windows Batch: Batch delete specified files from a specified directory.
Summary of pitfalls

Windows Batch: Batch delete specified files from a specified directory.

Windows Batch: Batch delete specified files from a specified directory.

You can use the following Windows batch commands to delete files and shortcuts with specified names from a given directory in bulk:

@echo off
set "rootDir=C:\your\root\directory"  //将 "C:\your\root\directory" 替换成您的目标根目录
set "fileName=newbie_guide.lnk"  //将 "newbie_guide.lnk" 替换成您要删除的文件名

for /r "%rootDir%" %%f in (%fileName%) do (
    del "%%f"
)

set "shortcutName=新手必读.lnk"  //将 "新手必读.lnk" 替换成您要删除的快捷方式名

for /r "%rootDir%" %%s in (*%shortcutName%) do (
    del "%%s"
)

Description:

  • @echo offDo not display batch processing commands in the command line.
  • set "rootDir=C:\your\root\directory"Store the path to the target root directory in a variable. rootDir Middle.
  • set "fileName=newbie_guide.lnk"The name of the file to be deleted is stored in a variable. fileName Middle.
  • for /r "%rootDir%" %%f in (%fileName%) do (del "%%f"):make use of for Iterate through all subdirectories within the specified directory to locate files with matching filenames and then use them. del Issue a command to delete them.
  • set "shortcutName=新手必读.lnk"The name of the shortcut to be deleted is stored in a variable. shortcutName Middle.
  • for /r "%rootDir%" %%s in (*%shortcutName%) do (del "%%s"):make use of for Iterate through all subdirectories within the specified directory to find files whose shortcut name matches the given name, and then use them. del Issue a command to delete them.

Note: In Windows batch scripts, variable names must be enclosed in two percent signs (%).%%) is used to represent.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

(PC+WAP) Home Decoration & Building Materials Website – pbootCMS Template; Download Marketing-Oriented Home Decoration Website Source Code – 0560

(PC+WAP) Home Decoration & Building Materials Website – pbootCMS Template; Download Marketing-Oriented Home Decoration Website Source Code – 0560 Practical Collection pbootcms Template

A PbootCMS-based marketing website template designed for the home decoration and building materials industry, featuring a light yellow color scheme that creates a warm and cozy home environment. The template is compatible with both PC and WAP devices, with a page design focused on product showcasing and brand identity. It is ideal for construction companies or building materials brands looking to build an online brand presence, thereby increasing the number of online customer inquiries and improving conversion rates. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password:...
👁 53
Responsive Travel Agency Website Template 0181

Responsive Travel Agency Website Template 0181 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the tourism and travel agency industry. Its fresh and sophisticated design makes it perfect for showcasing travel itineraries, attraction descriptions, travel guides and blogs, as well as tourism services. It helps travel agencies attract online visitors and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 54
Responsive automotive maintenance service website template – 0999

Responsive automotive maintenance service website template – 0999 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for the automotive maintenance services industry. Its professional automotive design style enables effective presentation of vehicle maintenance services, repair services, technical teams, and customer reviews. It helps automotive service providers attract car owners online and enhance their brand image. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 55
After enabling the Private Space feature in Qiniu Cloud Object Storage and subsequently activating the Timestamp-based Anti-Link Hijacking feature, how can you retrieve a download link using PHP?

After enabling the Private Space feature in Qiniu Cloud Object Storage and subsequently activating the Timestamp-based Anti-Link Hijacking feature, how can you retrieve a download link using PHP? Summary of pitfalls

This tool is really handy! After enabling the private space feature in Qiniu Cloud Object Storage, the timestamp-based防盗 linking feature was also activated. How can you obtain a download link? When the timestamp verification feature is enabled for your Qiniu Cloud Object Storage private space, you need to include a timestamp parameter when generating a temporary download link. Here are the specific steps: To obtain the download domain name for your private space: In the Qiniu Cloud backend, select the corresponding storage space, navigate to the "Domain Name Settings" page, and locate the section for the private space...
👁 212
(Adaptive mobile version) Simplified/Traditional Chinese bilingual PBootCMS template for hardware equipment manufacturers' corporate websites; Downloadable source code for general mining ore processing equipment websites – 0561

(Adaptive mobile version) Simplified/Traditional Chinese bilingual PBootCMS template for hardware equipment manufacturers' corporate websites; Downloadable source code for general mining ore processing equipment websites – 0561 Practical Collection pbootcms Template

A bilingual (Simplified and Traditional Chinese) mechanical and mining equipment PbootCMS corporate website template, compatible with both PC and WAP devices. The professional and practical design is ideal for machinery export enterprises to showcase their products. The multilingual support facilitates brand promotion for businesses in both domestic and international markets. Template Preview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 42
Responsive Tea Wholesale Company Website Template 0182

Responsive Tea Wholesale Company Website Template 0182 Practical Collection Yiyou template

An eyouCMS responsive website template designed specifically for tea wholesale companies. Its professional and practical design enables effective presentation of tea products, wholesale prices, supply chain advantages, and brand stories. This template helps tea wholesalers expand their online sales channels and attract distributor clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YououCMS | YououCMS...
👁 39