批处理文件来搜索android系统/app中是否存在.odex文件



我正在处理一个大型批处理文件,并有一个小的部分,我需要帮助。我想做以下事情。对于mod文件夹中的每个*.apk,在phone/system/app中搜索mod中文件名的.odex版本。打印它是否存在。下面是我到目前为止的代码。如果我删除for语句并键入apkname而不是变量,它将工作。但是一旦我添加了for行,它总是返回一个大于1的错误级别,所以不管它是否存在,它总是说它存在。非常感谢您的帮助。

SETLOCAL ENABLEDELAYEDEXPANSION
for /r "%~dp0"mod %%f in (*.apk) DO (
set apkname=%%~nf
set mobile_path=/system/app
adb shell ls %mobile_path% | find /c "!apkanme!.odex" >NUL
if %ERRORLEVEL% == 0 (
    echo the file exists
) else (
    echo the file does not exist
)
)

如果这里有一些错误和拼写错误,请尝试:

@echo off &SETLOCAL ENABLEDELAYEDEXPANSION
for /r "%~dp0mod" %%f in (*.apk) DO (
    set "apkname=%%~nf"
    set "mobile_path=systemapp"
    adb shell ls !mobile_path! | find /i "!apkname!.odex" >NUL
    if !ERRORLEVEL! equ 0 (echo the file exists) else echo the file does not exist
)

顺便说一句。我只知道批次,不知道adb

下面是工作批处理部分的最终结果。@echo off已经在批处理文件的另一部分设置了。

SETLOCAL ENABLEDELAYEDEXPANSION
for /r "%~dp0"mod %%f in (*.apk) DO (
    set apkname=%%~nf
    set mobile_path=/system/app
    adb shell ls !mobile_path! | find /c "!apkname!.odex" >NUL
    if !ERRORLEVEL! == 0 (
        echo the file exists
    ) else (
        echo the file does not exist
    )
)

最新更新