I'm attempting to use the adb pull command to copy only certain files (jpg) to my macbook. I tried "adb pull sdcard/mydir/*.jpg" but it apparently doesn't interpret wildcards. How can I get only the jpg files copied over? I have rooted the phone if that helps.
You can move your files to other folder and then pull whole folder.
adb shell mkdir /sdcard/tmp adb shell mv /sdcard/mydir/*.jpg /sdcard/tmp # move your jpegs to temporary dir adb pull /sdcard/tmp/ # pull this directory (be sure to put '/' in the end) adb shell mv /sdcard/tmp/* /sdcard/mydir/ # move them back adb shell rmdir /sdcard/tmp # remove temporary directory
#!/bin/bash HOST_DIR=<pull-to> DEVICE_DIR=/sdcard/<pull-from> EXTENSION=".jpg" for file in $(adb shell ls $DEVICE_DIR | grep $EXTENSION'$') do file=$(echo -e $file | tr -d "\r\n"); # EOL fix adb pull $DEVICE_DIR/$file $HOST_DIR/$file; done
Make it executable:
chmod +x pullFiles.sh
As to the short script, the following runs on my Linux host
#!/bin/bash HOST_DIR=<pull-to> DEVICE_DIR=/sdcard/<pull-from> EXTENSION="\.jpg" while read MYFILE ; do adb pull "$DEVICE_DIR/$MYFILE" "$HOST_DIR/$MYFILE" done < $(adb shell ls -1 "$DEVICE_DIR" | grep "$EXTENSION")
"ls minus one" lets "ls" show one file per line, and the quotation marks allow spaces in the filename.