Here is what I did in the batch script:
set cmd="adb shell ls | find /c "theFile" " FOR /F %%K IN (' !cmd! ') DO SET TEST=%%K if !TEST! GTR 0 ( echo the file exists ) else ( echo the file does not exist )
There may be several files that match the file name, so I decided to check for it greater than 0.
To check the exact match and use bash on Linux ( link ):
FILENAME_RESULT=$(adb shell ls / | tr -d '\015'|grep '^fileName$') if [ -z "$FILENAME_RESULT" ]; then echo "No fileName found." else echo "fileName found." fi
source share