标题: 文件分类、删除空文件夹的组合批处理有没有多余或错误? [打印本页]
作者: comicguests 时间: 2011-7-3 00:20 标题: 文件分类、删除空文件夹的组合批处理有没有多余或错误?
- @echo off
- setlocal enabledelayedexpansion
- :choose
- set /p "c=从头开始0 追加1 删除多余2"
- if /i "!c!"=="0" goto 1
- if /i "!c!"=="1" goto 2
- if /i "!c!"=="2" goto 3
- goto choose
- :1
- ::setlocal enabledelayedexpansion&cls
- path=%path%;%~d0\DOS\网络;%~d0\DOS\command\第三方命令行程序;
-
- %~d0\DOS\command;%~d0\DOS\源码;%~d0\DOS\sysbkup
- md F:\download\&cd.>F:\download\☆キラ☆.bat
- >>F:\download\☆キラ☆.bat echo @echo off&title
- >>F:\download\☆キラ☆.bat echo goto:kiriri
- >>F:\download\☆キラ☆.bat echo :comic
- >>F:\download\☆キラ☆.bat echo for /f "delims=" %%%%i in ^('dir
-
- /ad /b /s^^^|sort /r'^) do rd /q "%%%%i" 2^>nul
- >>F:\download\☆キラ☆.bat echo exit
- >>F:\download\☆キラ☆.bat echo :kiriri
-
- :start ============================================================
- set /p "str_key=输入关键词:"
- set /p "sourPath=输入文件夹地址:"
- >>F:\download\☆キラ☆.bat echo for /r %%%%a in (*%str_key%*.rmvb)
-
- do move %%%%~sa %sourPath%
- >>F:\download\☆キラ☆.bat echo for /r /d %%%%a in (*%str_key%*) do
-
- del /a /f /s "%%%%a\*.torrent"
- set "choice="&set/p choice=是否继续添加?(y/n):
- if /i "%choice%"=="y" goto:start
- if /i "%choice%"=="n" >>F:\download\☆キラ☆.bat echo goto:comic
- :end ==============================================================
- goto :eof
- :2
- setlocal enabledelayedexpansion
- sed -i "s/goto:comic/==============/g" ☆キラ☆.bat
- :start ============================================================
- set /p "str_key=输入关键词:"
- set /p "sourPath=输入文件夹地址:"
- >>F:\download\☆キラ☆.bat echo for /r %%%%a in (*%str_key%*.rmvb)
-
- do move %%%%~sa %sourPath%
- >>F:\download\☆キラ☆.bat echo for /r /d %%%%a in (*%str_key%*) do
-
- del /a /f /s "%%%%a\*.torrent"
- set "choice="&set/p choice=是否继续添加?(y/n):
- if /i "%choice%"=="y" goto:start
- if /i "%choice%"=="n" >>F:\download\☆キラ☆.bat echo goto:comic
- :end ==============================================================
- goto :eof
- :3
- setlocal
- set n=
- set f="☆キラ☆.bat"
-
- for /f "delims=* tokens=2" %%i in ('findstr /rc:" (.*\*.*\*.*) " %f%') do (
- if not defined _%%i (
- set str=%%i
- set /a n += 1
- setlocal enabledelayedexpansion
- echo [!n!] !str!
- for /f "tokens=1,2 delims=*" %%a in ("!n!*!str!") do (
- endlocal
- set _%%b=_
- set #%%a=%%b
- )
- )
- )
-
- :aki ============================================================
- set /p "str_key=删除哪个?:"
- setlocal enabledelayedexpansion
- findstr /vrc:" (.*\*!#%str_key%!\*.*) " !f! >..tmp
- endlocal
- move ..tmp %f%
-
- set "choice="&set/p choice=是否继续删除?(y/n):
- if /i "%choice%"=="y" goto:aki
- if /i "%choice%"=="n" exit
-
- endlocal
复制代码
补充说明:
目的1:生成一个批处理,可以将F:\download下的视频文件按名称分类移动到F:\视频\*文件夹下(包括子文件夹,若子文件夹里有种子文件,删除)然后删除已空的文件夹;
目的2:可以追加新内容到已生成的☆キラ☆.bat里;
目的3:显示关键词,按选择删除
作者: CUer 时间: 2011-7-3 11:50
你连代码的功能都不说清楚,别人如何从根本上帮你简化?
作者: batman 时间: 2011-7-3 12:23
真正优化后代码应在20行内。。。建议楼主去学习下more命令。。。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |