I use the following line in my windows batch
SET MOBILE_PATH=/mnt/sdcard/koinoxrista
SET FILE_BILL="adb shell ls %MOBILE_PATH% ^| find /c "Bill.txt" "
this line adb shell ls %MOBILE_PATH% | find /c "Bill.txt" gives me 1
I want to write an If statement that will do something if FILE_BILL equals 1 and something else if equals 0. How can i do this?
if %FILE_BILL% == 1 (
echo the file exists
) else (
echo the file does not exist
)
I always get the message file does not exist
Your question makes it appear that it is only important that Bill.txt exists (or not) in a given location, and not that
find /c "Bill.txt"gives1. If that is true, then when “Bill.txt” is in the output of the adb command, you can simply use%ERRORLEVEL%:SET MOBILE_PATH=/mnt/sdcard/koinoxrista adb shell ls %MOBILE_PATH% | find /c "Bill.txt" >NUL if %ERRORLEVEL% == 0 ( echo the file exists ) else ( echo the file does not exist )You can save %ERRORLEVEL% to some other variable for later use.