Skip to content

Instantly share code, notes, and snippets.

@aldafu
Created May 30, 2011 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save aldafu/999043 to your computer and use it in GitHub Desktop.
Save aldafu/999043 to your computer and use it in GitHub Desktop.
Copy utility shell script for use with Android debug bridge (adb). Supports wildcards when copying from remote source to local destination directory. Example: adb-cp.sh /sdcard/DCIM/Camera/*.jpg ~/
#!/bin/bash
function usage()
{
echo "USAGE: adb-cp.sh <remote> <local dir>"
exit 1
}
if [ $# -ne 2 ]; then
usage
fi
if ! [ -e $2 ]; then
mkdir -p $2
else
if ! [ -d $2 ]; then
echo "error: destion must be a directory"
usage
fi
fi
LIST=$(adb shell ls "${1}")
SAVEDIFS=${IFS}
IFS=$(echo -e "\n\r")
for i in ${LIST}; do
if [ -z $i ]; then
continue
fi
adb pull $i "$2"
done
IFS=${SAVEDIFS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment