Last active
July 2, 2020 16:25
-
-
Save nalf3in/7f09072454d80fbb2e833cda8bd0a9d6 to your computer and use it in GitHub Desktop.
Script to backup your Android phone photos, requires adb to be in your path
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
import subprocess | |
import os | |
DEVICE = "10.0.0.4:5555" | |
SEPARATOR = "---------------" | |
subprocess.run(["adb", "devices"], stdout=subprocess.DEVNULL) | |
subprocess.run(["adb", "connect", DEVICE], stdout=subprocess.DEVNULL) | |
subprocess.run(["echo", SEPARATOR], shell=True, stdout=subprocess.DEVNULL) | |
shell_output = subprocess.run(["adb", "shell", "ls -1 /sdcard/dcim/camera"], capture_output=True, text=True) | |
filenames = shell_output.stdout.splitlines() | |
os.makedirs("photos", exist_ok=True) | |
for name in filenames: | |
subprocess.run(["adb", "pull", f"/sdcard/dcim/camera/{name}", f"{os. getcwd()}/photos/{name}"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment