Created
March 5, 2014 05:26
-
-
Save Ruxton/9361771 to your computer and use it in GitHub Desktop.
Command line android screenshots via ADB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# droidshot: droidshot [filename] - Saves screenshots via ADB to filename | |
function droidshot() { | |
local formatter="%03d" | |
local file="$1" | |
local n=1 | |
local fn=$(printf "${formatter}" $n) | |
if [[ "$file" == "" ]]; then | |
file="droidshot-"$(date "+%d-%m-%Y-") | |
files=`ls ${file}* 2>/dev/null|awk '{print $1}'` | |
ext=".png" | |
for i in $files; do | |
echo $i | |
echo "${file}${fn}${ext}" | |
if [[ "${file}${fn}${ext}" == "${i}" ]]; then | |
n=$(( n + 1 )) | |
echo $n | |
fi | |
fn=$(printf "${formatter}" $n) | |
done | |
file="${file}${fn}${ext}" | |
fi | |
echo "Screenshotting to ${file}.." | |
adb shell screencap -p 2> /dev/null | perl -pe 's/\x0D\x0A/\x0A/g' > $file | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment