![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-10-01 19:13 |
共 47,813 主题排行 / 349,918 发帖 / 今日 0 篇 / 48,279 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » [原创]自动搜索并删除畸形文件夹 |
| 可打印版本 996 / 2 |
| 第1楼 q1x2x3 | 发表于 2010-01-22 14:42 |
| 新手上路 发帖 9 积分 12 | |
|
[原创]自动搜索并删除畸形文件夹 set alldrive=a b c d e f g h i j k l m n o p q r s t u v w x y z
for %%i in (%alldrive%) do if exist %%i:\ dir /ad /s /b %%i:\|(findstr /e "\.") >>1.txt set /p var=<1.txt echo rd /s /q \\?\^"%var%^">1001.bat echo del 1.txt>>1001.bat echo del 1001.bat>>1001.bat 这个批处理是自己写的,仅供大家参考学习,这个批处理有个缺点就是一次只能删除一个畸形文件夹,以后有机会的话做完善点,现在只能找以.结尾的畸形文件夹 至于。。畸形文件夹,大家可以去百度找资料,只要以.为后缀的文件夹都可以删除 谨慎使用,rd /s /q \\?\这句命令很可能删除你本来不想删除的文件,所以。。。 |
|
| 第2楼 q8249014 | 发表于 2010-01-22 19:15 |
| 初级用户 发帖 45 积分 175 | |
|
一般我们所认为的畸形文件夹为:md test..\\
删除方法为:rd /s /q test..\\ 你的代码好像有问题 |
|
| 第3楼 tongzj | 发表于 2010-01-24 08:20 |
| 初级用户 发帖 43 积分 49 | |
|
下面是我以前做的删除带点目录脚本,利用 8.3 格式名,生成一个command.bat,删除前可以先看到要删除的目录,避免误删。
@echo off setlocal enabledelayedexpansion echo :: 请确认可以删除以下文件后再执行command.bat>command.bat echo :: 不需要删除的目录请务必删除本文件中的条目>>command.bat echo :: 如果下面为空表明未找到带点目录>>command.bat echo ::===========================================>>command.bat :input set /p dir=请输入绝对目录名: if "%dir%"=="" goto input if not exist %dir% goto input echo 正在查找 %dir%下带.目录 for /f %%a in ('dir /ad /s /b "%dir%" ^|findstr /e /c:"."') do (call :start %%a) start notepad command.bat goto :eof :start set PA=%1 set num=0 :loop1 set FN1=!PA:~%num%! echo %FN1% |find "\">nul if !errorlevel!==0 ( set /a num+=1 goto loop1 ) else ( set PN=!PA:~0,%num%! set FN=%FN1% goto loopout ) :loopout call :countlenth %PA% set PAL=%lenth% call :countlenth %PN% set PNL=%lenth% call :countlenth %FN% set FNL=%lenth% for /f "tokens=4,5" %%y in ('dir /ad /x %PN%^|findstr /i /e /c:" %FN%"') do ( findstr /i /b /e /c:"rd /s /q %PN%%%y" command.bat>nul if not !errorlevel!==0 ( >>command.bat echo :: 删除目录 %PN%%%z >>command.bat echo rd /s /q %PN%%%y ) ) goto :eof :countlenth set str=%1 set num=0 set lenth=0 :loop if "!str:~%num%,1!"=="" ( set lenth=%num% goto :eof ) set /a num=1+%num% goto loop |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |