Last active
June 30, 2021 12:05
-
-
Save danybony/d8bdb15445b4c3965f6196c6213fc545 to your computer and use it in GitHub Desktop.
Android screenshot to current dir
This file contains hidden or 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 | |
while getopts y: flag | |
do | |
case "${flag}" in | |
y) size=${OPTARG};; | |
esac | |
done | |
DEVICES=`adb devices | grep -v devices | grep device | cut -f 1` | |
for device in $DEVICES; do | |
output="screen_$(echo $device)_$(date +%Y%m%d_%H%M%S).png" | |
echo "Capturing from $device" | |
adb -s $device shell screencap -p /sdcard/screen.png | |
adb -s $device pull /sdcard/screen.png $output | |
adb -s $device shell rm /sdcard/screen.png | |
if [ ! -z $size ] | |
then | |
sips -Z $size $output | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the script!
I've modified it a bit to suit my need (working with devices with multiple screens like the Samsung Z Fold):
BTW: Using
exec-out
you can avoid to generate the file on the device and then copy/delete it.