Created
August 8, 2023 14:38
-
-
Save PhilipDukhov/0e783e5f22e63f123321def77a816aca to your computer and use it in GitHub Desktop.
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 | |
# don't forget to do `chmod +x screencap.sh` in the script location | |
adb devices | tail -n +2 | while read line | |
do | |
deviceId=$(echo $line | awk '{print $1}') | |
if [ -z "${deviceId}" ]; then | |
continue | |
fi | |
if [[ $line == *"emulator"* ]] | |
then | |
deviceName=$deviceId | |
else | |
deviceName=$(echo $line | awk -F "device:" '{print $2}' | awk '{print $1}') | |
fi | |
echo "Capturing screenshot from device $deviceName" | |
timestamp=$(date +"%Y-%m-%d at %H.%M.%S") | |
filename="Android Screenshot - $deviceName - $timestamp.png" | |
adb -s $deviceId exec-out screencap -p > "$filename" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment