As I was working on making a package of the very best of older android device games, I got AI to help me make a script that will install a folder full of them to a connected USB Debugging device... here is the code it's given, it works a treat, You do need to install the adb, I might go make it do that for you too 

It's made me able to leave windows behind for another reason, I'll see how it goes with iDevices another day, but for now, this is great.#!/usr/bin/env bash
DEFAULT_BASE_DIR="/media/glenn/Glenn_s 8TB USB/1-Other_Consoles/Android2025/Games-Android4.4.x/Best"
WAIT_SECONDS=5
STATE_FILE="/tmp/apk_install_resume.state"
ADB_SERIAL=""
# Use full argument string as path if provided
if [ "$#" -gt 0 ]; then
BASE_DIR="$*"
else
BASE_DIR="$DEFAULT_BASE_DIR"
fi
# Validate path
if [ ! -d "$BASE_DIR" ]; then
echo "Directory does not exist:"
echo " $BASE_DIR"
exit 1
fi
# Tool checks
for cmd in adb aapt; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Required tool missing: $cmd"
exit 1
fi
done
echo " Using APK source directory:"
echo " $BASE_DIR"
echo
# ---- wait for device and select ----
select_device() {
while true; do
mapfile -t DEVICES < <(adb devices | awk 'NR>1 && $2=="device" {print $1}')
if [ "${#DEVICES[@]}" -eq 1 ]; then
ADB_SERIAL="${DEVICES[0]}"
echo "Android device detected: $ADB_SERIAL"
echo -e "\a" # Beep
return
fi
if [ "${#DEVICES[@]}" -gt 1 ]; then
echo " Multiple Android devices detected:"
for i in "${!DEVICES[@]}"; do
echo " [$i] ${DEVICES[$i]}"
done
echo
read -rp "Select device number: " SEL
if [[ "$SEL" =~ ^[0-9]+$ ]] && [ "$SEL" -lt "${#DEVICES[@]}" ]; then
ADB_SERIAL="${DEVICES[$SEL]}"
echo "Selected device: $ADB_SERIAL"
echo -e "\a" # Beep
return
fi
echo "Invalid selection"
fi
echo
echo "Waiting for Android device..."
echo " Plug in a Android device with USB Debugging Enabled"
echo " Press Build number 8 times under About"
echo " Enable USB Debugging in Developer Options"
echo
adb devices
echo
echo " Retrying in $WAIT_SECONDS seconds..."
sleep "$WAIT_SECONDS"
done
}
select_device
echo
ADB="adb -s $ADB_SERIAL"
# ---- load APK list ----
mapfile -d '' APKS < <(find "$BASE_DIR" -type f -iname "*.apk" -print0)
TOTAL=${#APKS[@]}
if [ "$TOTAL" -eq 0 ]; then
echo "No APK files found"
exit 0
fi
# Resume support
START_INDEX=0
if [ -f "$STATE_FILE" ]; then
START_INDEX=$(cat "$STATE_FILE")
echo " Resuming from APK $((START_INDEX+1)) of $TOTAL"
fi
echo " Found $TOTAL APK(s)"
echo " Starting install..."
echo
# ---- install loop ----
for ((i=START_INDEX; i<TOTAL; i++)); do
APK="${APKS[$i]}"
FILE_NAME="$(basename "$APK")"
COUNT=$((i+1))
PERCENT=$((COUNT * 100 / TOTAL))
echo "[$COUNT/$TOTAL] ($PERCENT%) Checking: $FILE_NAME"
PKG=$(aapt dump badging "$APK" 2>/dev/null | awk -F"'" '/package: name=/{print $2}')
if [ -z "$PKG" ]; then
echo "Could not read package name, skipping"
continue
fi
if $ADB shell pm list packages | grep -q "^package:$PKG$"; then
echo "Already installed: $PKG"
continue
fi
echo " Installing: $FILE_NAME"
if $ADB install -r "$APK"; then
echo "Installed: $PKG"
else
echo "Install failed or device disconnected"
echo "$i" > "$STATE_FILE"
select_device
ADB="adb -s $ADB_SERIAL"
continue
fi
echo
done
rm -f "$STATE_FILE"
echo -e "\a"
echo " All done!"