我正在写一个我写的Bat文件的问题。
图片:http://i67.photobucket.com/albums/h308/denash1/files.png
(我暂时不允许发布图片)
“EXTRACT_ALL(no_decompression).bat中的脚本如下:
@echo off
for /r %%f in (*.cpk) do (
SET filename=%%~nf)
mkdir %filename%
copy %filename%.cpk .\%filename%
copy CriPakTools.exe .\%filename%
cd %filename%
for /r %%f in (*.cpk) do "CriPakTools.exe" "%%f" ALL
pause
每次运行此代码时,它第一次运行正常,它找到文件“725.cpk”,然后将其放入文件夹725,然后将内容提取到该文件夹中,这很好。< / p>
但是第二次运行它时,它仍然只移动并提取文件725.cpk并忽略其他CPK文件。
即使我删除文件“725.cpk”,它也会抱怨文件丢失。 有人可以帮助我并解释为什么.cmd文件永远不会检查另一个文件,即“110638.cpk”,因为它在同一目录中?
非常感谢你的帮助!
答案 0 :(得分:0)
(未经测试的代码)
@echo off
REM with every file fitting to this file mask do the following:
for %%f in (*.cpk) do (
REM get the name only ,without path or extension and make a directory with this name, redirect "already exist" message to NUL:
mkdir %%~nf 2>nul
REM copy the file to the new folder:
copy %%f .\%%~nf
REM copy another file to the same destination:
copy CriPakTools.exe .\%%~nf
REM set the working directory to the new folder
pushd %%~nf
REM execute the tool:
"CriPakTools.exe" "%%f" ALL
REM go back to previous working directory:
popd
)
pause