Last active
August 7, 2025 08:57
-
-
Save niraj-shah/6ce7f04fa318728e771f7289f98d9a7c to your computer and use it in GitHub Desktop.
Shell script to copy only new files using adb
This file contains hidden or 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
# path to folder on the device | |
PHONE_PATH=/storage/self/primary/DCIM/Camera/ | |
# path to copy files to | |
LOCAL_PATH=~/Camera/ | |
# get list of files from the phone folder | |
adb shell ls -l $PHONE_PATH > file_list.txt | |
# filter only jpg and mp4 files | |
grep ".[jpg|mp4]" file_list.txt | awk '{print $NF}' > files_to_pull.txt | |
# to copy all files, change line 11 to: | |
# awk '{print $NF}' < file_list.txt > files_to_pull.txt | |
# copy each file | |
while IFS= read -r file_path; do | |
if [ -f "$LOCAL_PATH/$file_path" ]; then | |
echo "$file_path already exists" | |
else | |
adb pull -a "$PHONE_PATH"/"$file_path" "$LOCAL_PATH" | |
fi | |
done < files_to_pull.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment