Skip to content

Instantly share code, notes, and snippets.

@PhilipDukhov
Created August 8, 2023 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PhilipDukhov/0e783e5f22e63f123321def77a816aca to your computer and use it in GitHub Desktop.
Save PhilipDukhov/0e783e5f22e63f123321def77a816aca to your computer and use it in GitHub Desktop.
#!/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