How can you reliably move files from android to windows pc?

Viewed 32

I'm trying to set up a bash script that can move video files (.mp4) from my android phone to my windows PC (or more accurately, to an external SSD). The goal is to save time transferring files as I will be doing this multiple times a day in between other things, so I want to do it automatically.

I know that it's possible to use adb pull to move the files and then use adb shell to delete them on the phone afterwards, but I am worried that if adb pull fails, it might delete some of the video files. Hence, I am looking for a solution that checks if the files were transferred correctly before deleting them from the phone.

1 Answers

Check the exit status of the command and delete if there is not error

#!/bin/bash

file=/data/local/tmp/file1
if adb pull "$file"
then
    adb shell rm "$file"
fi
Related