Answer the question
In order to leave comments, you need to log in
How to rewrite this piece of code under BASH?
Goodnight! There are two pieces of code:
1.
FOR %%F IN (assets lib libs unknown) DO (
if exist "_INPUT_APK\%~1\%%F" (
FOR /f "tokens=1* delims= " %%a IN ('sfk list -hidden -quiet -quot -relnames "_INPUT_APK\%~1\%%F" -sincedir "_INPUT_APK\%~1\_backup\%%F" 2^>nul') DO (
if /I %%F==assets (call :copy2 "_INPUT_APK\%~1\assets\%%~b" "_INPUT_APK\%~1\_backup\upd\0\assets\%%~b")
if /I %%F==lib (call :copy2 "_INPUT_APK\%~1\lib\%%~b" "_INPUT_APK\%~1\_backup\upd\7\lib\%%~b")
if /I %%F==libs (call :copy2 "_INPUT_APK\%~1\libs\%%~b" "_INPUT_APK\%~1\_backup\upd\7\libs\%%~b")
if /I %%F==unknown (call :copy2 "_INPUT_APK\%~1\unknown\%%~b" "_INPUT_APK\%~1\_backup\upd\0\%%~b")
)
if %delete_resources_in_expert_mode%==ON (
FOR /f "tokens=1* delims= " %%a IN ('sfk list -hidden -quiet -quot -relnames "_INPUT_APK\%~1\_backup\%%F" -sinceadd "_INPUT_APK\%~1\%%F" 2^>nul') DO (
if /I %%F==assets (echo assets\%%~b>>"_INPUT_APK\%~1\_backup\upd\delete.list")
if /I %%F==lib (echo lib\%%~b>>"_INPUT_APK\%~1\_backup\upd\delete.list")
if /I %%F==libs (echo libs\%%~b>>"_INPUT_APK\%~1\_backup\upd\delete.list")
if /I %%F==unknown (echo %%~b>>"_INPUT_APK\%~1\_backup\upd\delete.list")
)
)
Answer the question
In order to leave comments, you need to log in
Try to build a construct from find and xargs, in which case the loop is not explicitly required.
lots of examples: https://www.google.com/search?q=find+xargs
If this is not enough, then you can add awk, it will be more complicated, but the possibilities are widest.
Take and write. There are loop, conditional, comparison, string parsing operators in bash :)
Maybe you don’t need to fence all these cycles at all, but just read the help on rsync and make everything rsync?
It can compare and copy folders and generate a file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question