Last active
September 13, 2018 12:35
-
-
Save vrendina/ffcc09500c4f698568c1a6d293c94213 to your computer and use it in GitHub Desktop.
Automatically create and resize Android screenshots from multiple devices on OSX
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/sh | |
# | |
# Take a screenshot from a connected device, resize it, and automatically save it | |
# to the OUTPUT_DIR. You should edit the output directory and desired maximal | |
# dimension of the resulting image. Each image will be output with [devicename]-[timestamp]. | |
# If you have multiple devices connected this will take a screenshot from each device. | |
# | |
# This script is designed to work with OSX. | |
# | |
OUTPUT_DIR="/Users/victor.rendina/Desktop" | |
OUTPUT_MAX_DIMEN=640 | |
if [ -z $(which adb) ]; then | |
echo "$0 error: adb must be installed and in PATH." | |
exit 1 | |
fi | |
DEVICE_COUNT=$(adb devices | grep device$ | wc -l) | |
if [ $DEVICE_COUNT -eq 0 ]; then | |
echo "No devices connected." | |
exit 1 | |
fi | |
for device in `adb devices | grep device$ | cut -f1` | |
do | |
file="$device-$(date +'%s').png" | |
remote="/sdcard/$file" | |
local="$OUTPUT_DIR/$file" | |
echo "Creating screenshot $file..." | |
adb -s $device shell screencap -p $remote | |
adb -s $device pull $remote $local > /dev/null | |
adb -s $device shell rm $remote | |
sips -Z $OUTPUT_MAX_DIMEN $local > /dev/null | |
done | |
echo "Complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment