Skip to content

Instantly share code, notes, and snippets.

@nuvious
Last active July 25, 2025 01:41
Show Gist options
  • Save nuvious/da055f0895cc2e6f41a7b7a99f812372 to your computer and use it in GitHub Desktop.
Save nuvious/da055f0895cc2e6f41a7b7a99f812372 to your computer and use it in GitHub Desktop.
Pull all apks from all android deviecs with adb.
#!/bin/bash
# Author: David Cheeseman
# Desc: Quick script to pull all apks (including splits) from all android
# device attached to the machine with USB debugging enabled.
# Make a directory for the apks
mkdir -p apks
pushd apks
# For each device
for device in `adb devices | grep -v List | cut -f1`; do
# Make a device specific directory and move into it
mkdir -p $device
pushd $device
# Then for every package in the package list
for package in `adb -s $device shell pm list packages -f`; do
# Get the package directory by splitting off at the first :...
package_path=${package#*:}
# Then before the last =...
package_path=${package_path%=*}
# Then before the last / character.
package_path=${package_path%\/*}
# Get the relative path of the package from root
package_relative_path=${package_path#*\/}
# Make a path for the specific package path
mkdir -p $package_relative_path
pushd $package_relative_path
# Then for every apk file in that directory
for apk_path in `adb shell ls $package_path/*.apk`; do
# Pull it
adb pull $apk_path
done
# Back out to device level path
popd
done
# Pop back out for the next device
popd
done
# Pop back out to the working directory
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment