In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what are the methods of deleting folders in batches according to requirements using batch processing". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn together "what are the methods of deleting folders in batches according to requirements using batch processing"!
Example 1:
There are a bunch of folder structures like this, for example
abcde
|-----abcd2000
|---------0003
|----------0004
........
|------abcd2001
|---------0006
|----------0002
........
|------abcd2002
|---------0005
|----------0002
........
cdefe
|-----cdefe2000
|---------0003
|----------0004
........
|------cdefe2001
|---------0006
|----------0002
........
|------cdefe2002
|---------0005
|----------0002
........
Now I want to delete the second level directory according to the year, for example, only delete the directory containing 2000 and 2001 fields such as abcd2000,abcd2001, cdefe 2000,cdefe2001 and its lower level directory. What should I do?
@echo offsetlocal enabledelayedexpansion:: set primary folder set folder=D:\abcdefor /f "delims=" %%a in ('dir/ad /b %folder %') do ( set str=%%a if "! str:~-4! "=="2000" rd %folder%\! str! /s /q if "! str:~-4! "=="2001" rd %folder%\! str! /s /q)
Example 2:
All my pictures are saved in F:\Photography, and there are N folders below, all of which have a file called ".picasaoriginals". There is a dot before this name!!!
For example, F:\Photography\I @\I @ Qingdao\.picasaoriginals
Now we need a batch process to delete all F:\Photography subfolders that contain.picasaoriginals.
And, just to be safe... Please prompt the program if you want to delete this information...
@echo offecho Scanning files... for /f "delims=" %%a in ('dir /a-d /s /b .picasaoriginals') do (if /i "%%~nxa"==".picasaoriginals" (if exist "%%~a" (echo del /f /q "%%~a">DelNow.bat))if exist "DelNow.bat" (ping 0 -n "2">nulcall:qd)del /f /q DelNow.batexit :qdclsset /p q= Confirm deletion? (Enter Y OK, others exit): clsif /i "%q%"=="Y" (echo is deleting... ping 0 -n "2">nulcall DelNow.batclsecho Delete complete! ping 0 -n "2">nul)goto :eof
Example 3:
Delete all files and folders with qqq in batch
@echo offecho.... File search, please wait... c:\for /r c: %%a in (.) do @if exist %%a\qqq.* del %%a\qqq.* for /r c: %%a in (.) do @if exist %%a\qqq rd /s /q %%a\qqqd:\for /r d: %%a in (.) do @if exist %%a\qqq.* del %%a\qqq.* for /r d: %%a in (.) do @if exist %%a\qqq rd /s /q %%a\qqqe:\for /r e: %%a in (.) do @if exist %%a\qqq.* del %%a\qqq.* for /r e: %%a in (.) do @if exist %%a\qqq rd /s /q %%a\qqqf:\for /r f: %%a in (.) do @if exist %%a\qqq.* del %%a\qqq.* for /r f: %%a in (.) do @if exist %%a\qqq rd /s /q %%a\qqqgoto end:endecho good bye! Thank you for reading, the above is "what are the methods of using batch processing to delete folders in batches as required", after learning this article, I believe everyone has a deeper understanding of what methods are used to delete folders in batches as required, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.