0

我的主脚本中有一个脚本,但此部分无法正常运行

您可以在此处下载完整的内容,其中包含我正在处理的更改,并且在理论上他们应该进行的更改似乎无法开始工作

http://apkmultitool.com/downloads/APK-Multi-Tool-Test-Build.zip

  CLS
ECHO Weclome to the Batch Optimization Menu
ECHO You have one of three options
ECHO 1 Batch Zipalign
ECHO 2 Batch Optomize PNG Files
ECHO 3 Batch Optomize PNG Files as well as ZIPALIGN APK files afterword.
set /P INPUT=Type input 1 - 3: %=%
if (%INPUT%)==1 GOTO zipo
if (%INPUT%)==2 GOTO ponly
if (%INPUT%)==3 GOTO zipb

:zipo
FOR %%F IN (place-apk-here-to-batch-optimize\*.apk) DO (call :zipoa "%%F")
:zipoa
IF %1 == () goto zipob
cd other
Start "Starting Batch Zipalign of APK Files" batchzip01
goto restart
:zipob
ECHO Folder is empty please place files inside and try again
PAUSE
goto restart
:ponly
FOR %%F IN (place-apk-here-to-batch-optimize\*.apk) DO (call :ponlya "%%F")
:ponlya
IF %1 == () goto ponlyb
cd other
Start "Starting Batch Optomize of PNG Files" batchopt01
goto restart
:ponlyb
ECHO Folder is empty please place files inside and try again
PAUSE
goto restart
:zipb
FOR %%F IN (place-apk-here-to-batch-optimize\*.apk) DO (call :zipba "%%F")
:zipba
IF %1 == () goto zipbb
cd other
Start "Starting Batch Optomize of PNG Files as well as Zipalign of APK Files " batchopt02
goto restart
:zipbb
ECHO Folder is empty please place files inside and try again
PAUSE
goto restart

但是当我尝试运行三个选项中的任何一个时,它们会挂起,例如当我运行同时运行 roptipng 和 zipalign 的选项时,它只是在 Cding 进入文件夹后坐在那里

batchopt01.bat

@echo off 
cd ../place-apk-here-to-batch-optimize
FOR %%F IN (*.apk) DO (call :optipng "%%F")

:optipng
IF %1 == () goto end

:: makes working folders
md "..\optimized"
md "%~dp0untouched"
md "%~dp0apkopt_temp_%~n1"


:: uncompressing contents of apks
"%~dp07za.exe" x -o"%~dp0apkopt_temp_%~n1" %1

:: moves 9.png files to a seperate folder before optomizing normale png files
mkdir "%~dp0temp"
xcopy "apkopt_temp_%~n1\res\*.9.png" "%~dp0temp" /S /Y

:: -o* (0-99) specifies how much the image is optimized
"%~dp0roptipng.exe" -o99 "%~dp0apkopt_temp_%~n1\**\*.png"
xcopy "%~dp0temp" "%~dp0apkopt_temp_%~n1\res" /S /Y
rmdir "%~dp0temp" /S /Q
copy /b %1 "..\untouched"
del /q %1

:: -mx%usrc% (0-9) indicates the compression level used for all working apks
"%~dp07za.exe" a -tzip "..\optimized\%~n1.apk" "%~dp0apkopt_temp_%~n1\*" -mx%usrc% -mmt
rd /s /q "%~dp0apkopt_temp_%~n1"

:end
ECHO Batch Optomize of PNG Files Completed.
PAUSED 
exit

batchopt02.bat

@echo off
cd ../place-apk-here-to-batch-optimize
FOR %%F IN (*.apk) DO (call :optipng "%%F")

:optipng
IF %1 == () goto end

:: makes working folders
md "..\optimized"
md "%~dp0untouched"
md "%~dp0apkopt_temp_%~n1"


:: uncompressing contents of apks
"%~dp07za.exe" x -o"%~dp0apkopt_temp_%~n1" %1

:: moves 9.png files to a seperate folder before optomizing normale png files
mkdir "%~dp0temp"
xcopy "%~dp0apkopt_temp_%~n1\res\*.9.png" "%~dp0temp" /S /Y

:: -o* (0-99) specifies how much the image is optimized
"%~dp0roptipng.exe" -o99 "%~dp0apkopt_temp_%~n1\**\*.png"
xcopy "%~dp0temp" "%~dp0apkopt_temp_%~n1\res" /S /Y
rmdir "temp" /S /Q
copy /b %1 "%~dp0untouched"
del /q %1

:: -mx%usrc% (0-9) indicates the compression level used for all working apks
%~dp07za.exe" a -tzip "..\optimized\%~n1.apk" "%~dp0apkopt_temp_%~n1\*" -mx%usrc% -mmt
rd /s /q "%~dp0apkopt_temp_%~n1"

:end
ECHO Batch Optomize of PNG Files Completed Now Beginig Zipalign functions.
cd "%~dp0"
Start "Starting Batch Zipalign of APK Files" batchzip02 
exit

batchzip01.bat

@echo off
cd ../place-apk-here-to-batch-optimize
FOR %%F IN ("*.apk) DO (call :zipalign "%%F")

:zipalign
IF %1 == () goto end

:: makes working folder
md "../zipaligned"

:: -zipalign -v * (4) indicates the amount of bytes used to optimize apks
"%~dp0zipalign.exe" -v 4 "%~n1.apk" "../zipaligned\%~n1.apk"
del /q %1

:end
exit

batchzip02.bat

@echo off
cd ../optimized
FOR %%F IN ("*.apk) DO (call :zipalign "%%F")

:zipalign
IF %1 == () goto end

:: makes working folder
md "..\zipaligned"

:: -zipalign -v * (4) indicates the amount of bytes used to optimize apks
"%~dp0zipalign.exe" -v 4 "%~n1.apk" "..\zipaligned\%~n1.apk"
del /q %1

:end
exit
4

2 回答 2

0

批处理总是通过匹配字符串来工作,并且对过程块没有任何概念。

因此

if (%INPUT%)==1 GOTO zipo

例如,尝试将“(1)”匹配到“1”(如果您的输入是“1”)并失败,因此继续执行下一条语句。

因此它将失败三个选项测试并继续执行FOR以下操作:zipo

不知道是否place-apk-here-to-batch-optimize\*.apk存在, :zipoa 将使用 "%%F" 参数调用 - 带引号的文件名

如果此类文件不存在,则输入 :zipoa 并使用参数 [无论您首先给批处理提供什么参数]

如果 :zipoa 在没有参数的情况下到达,你会得到一个语法错误

 IF %1 == () goto zipob

因为if == () ...是无效的语法。

你没有报告这个,所以看起来 :zipoa 确实是用一个参数调用的——这不太可能匹配(),所以goto zipob没有执行,我们继续......

cd other
Start "Starting Batch Zipalign of APK Files" batchzip01
goto restart

因此,batchzip01 作为一个单独的进程启动,然后当前进程进入您没有向我们展示的标签重新启动,所以从那里会发生什么,我不知道。

于 2013-05-03T02:08:50.920 回答
0

在您的脚本中,将 START 命令替换为 CALL。抛弃评论。

Start "Starting Batch Zipalign of APK Files" batchzip01

变成

Call batchzip01
于 2013-05-02T19:05:58.263 回答