:: DDK Source Files Allot :: 从DDK的cab中解压出来的文件没有目录层级,但每个文件的文件名中包含了该文件所应 :: 处于的位置。本批处理将处理单个目录中的所有文件,解析每个文件名,将之改为正确 :: 名称并放入正确位置。 经测试适用于98DDK :: Author: ZeroFire(炽火) :: ver beat0.1[20080910] @echo off setlocal enabledelayedexpansion rem mode con lines=26 color 1f cls title 批量处理DDK中解压的文件名 set fullpath=%~dp0 set selfname=%~nx0 :start set oldname= :: 遍历当前目录下的所有文件 for /f "usebackq delims=" %%f in (`dir /b/a-d .`) do ( set "var=%%~nf" for /f "tokens=1,2,3,4,5,6,7,8,9* delims=_" %%i in ("!var!") do ( call :mkdir %%f %%i %%j %%k %%l %%m %%n %%o %%p %%q ) ) goto ok :: 函数mkdir按照给定参数顺序检查是否存在匹配的目录树,如果不存在则创建该目录 :: 然后将文件改为正确名称后移动到正确位置 :: %1是目标文件名 %2~9之后是目录树 :mkdir if "%3"=="" ( goto :EOF ) set shortname=%1 :loop if "%3"=="" ( move "%fullpath%%1" "!shortname!" set shortpath=%CD% set "shortpath=!shortpath:%fullpath%=!" echo !shortpath!\!shortname! ) else ( if not exist "%2" ( md "%2" ) cd "%2" set "shortname=!shortname:%2_=!" shift /2 goto loop ) cd %fullpath% goto :EOF :: 显示成功信息并退出 :ok echo done ^^_^^ pause >nul goto :EOF
DDK Source Files Allot
最新推荐文章于 2021-05-23 08:54:12 发布