0

I have a script in my main script but this section will not function correctly

you can download the full thing here with the changes i am working on and cant seemt to get to work when in theory they should

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

but when I try to run any of the three option they hang for example when I run the option to run both roptipng and zipalign it just sit there after Cding into the folder

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
raziel23x
  • 71
  • 1
  • 8

2 Answers2

0

In your scripts, replace the START commands with CALL. Ditch the comments.

Start "Starting Batch Zipalign of APK Files" batchzip01

becomes

Call batchzip01
Tony
  • 2,658
  • 2
  • 31
  • 46
  • now all three options give this error '"Starting Batch Zipalign of APK Files"' is not recognized as an internal or external command, operable program or batch file. '"Starting Batch Zipalign of APK Files"' is not recognized as an internal or external command, operable program or batch file. '"Starting Batch Zipalign of APK Files"' is not recognized as an internal or external command, operable program or batch file. '"Starting Batch Zipalign of APK Files"' is not recognized as an internal or external command, operable program or batch file. – raziel23x May 02 '13 at 19:14
  • when i change it for example to the call batchzip01 now the main script closes and nothing happens when it is suppose to send the main script back to the main menu list and open a separate windows to do the batch script – raziel23x May 02 '13 at 19:20
  • Try removing the `exit`s of the called scripts or replace with `exit /b` – Patrick Meinecke May 02 '13 at 21:40
0

Batch ALWAYS works by matching strings and has no concept whatever about procedure-blocks.

Hence

if (%INPUT%)==1 GOTO zipo

for example attempts to match "(1)" to "1" (if your input was "1") and fails, so proceeds to the next statement.

It will therefore fail the three option tests and proceed to the FOR following :zipo

No idea whether place-apk-here-to-batch-optimize\*.apk exists if it does, :zipoa will be called with a parameter of "%%F" - a quoted filename

If such files do NOT exist, :zipoa is entered with parameter of [whatever parameters you gave the batch in the first place]

If :zipoa is reached with no parameters, you'll get a syntax-error on

 IF %1 == () goto zipob

because if == () ... is invalid syntax.

You don't report this, so it appears :zipoa is indeed being called with a parameter - which is unlikely to match () so the goto zipob is not executed and we proceed...

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

So batchzip01 is started as a separate process and the current process then goes to the label restart which you haven't shown us, so what happens from there, I have no idea.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Well there is a link in the original question which you can download the full script which contains everything to run including test files inside the folder. also it is option 19 from the main menu. – raziel23x May 03 '13 at 15:22