I'm trying to pull Whatsup images from my android phone via ADB using the following script:
HOST_DIR=/myImageDirectory
DEVICE_DIR="/sdcard/WhatsApp/Media/WhatsApp\ Images"
echo started
for file in $(./adb shell ls $DEVICE_DIR)
do
file=$(echo -e $file | tr -d "\r\n");
# EOL fix
echo $file
./adb pull $DEVICE_DIR/$file $HOST_DIR/;
done
The space in the source directory is escaped successfully for ls but not for pull. That is, i get the list of files but cannot pull them.
Here are 3 lines of the output:
IMG-20171101-WA0003.jpg
adb: error: remote object '/sdcard/WhatsApp/Media/WhatsApp\' does not exist
adb: error: remote object 'Images/IMG-20171101-WA0003.jpg' does not exist
What gives?