2

In order to not run out of space on my Android, I often move all pictures to my desktop computer, via USB. I do it almost everyday, as I also fear losing my pictures if I drop my phone.

Problem: It takes a lot of time, because various Android apps put their pictures in various folders (stock camera app, favorite camera app, HDR camera app, Foodie camera app, plus all messaging apps that store received pictures in their own folder, sometimes even separating between photos and videos).

So, I am looking for a tool that would move all pictures from all of these folders.

Requirements:

  • Runs on recent Linux
  • Compatible with Android 7+
  • Command-line, it should do the transfers without asking or showing any UI, or at most a desktop notification after transfer is done
  • Open source and gratis
  • Due to a limited data plan, Internet transfer is not an option, it must be via USB. I connect via USB everyday to charge the device so it does not bother me.

It could allow me to configure the paths I want pictures to be moved from, or it could download from the usual folders where well-known apps put their pictures.

0

2 Answers 2

3

What about a shell script using adb pull to retrieve the files and, after a successfull transfer, performs adb shell 'rm <filespec>'? You can easily setup the locations as array to walk.

Alternatively, using adbfs you could mount your device and then deal with its storage as if it were local – so any tools available to perform such a task on Linux would be at your disposal, making the task less error-prone. Raw skeleton:

# folders on your Android device, where they are mounted by adbfs:
declare -a SRCDIRS=(/mnt/android/folder1 /mnt/android/folder2)
# root folder on your Linux machine, where they should go to:
TARGETROOT="/home/nicolas/Pictures"

# Now move them over:
for sdir in $SRCDIRS; do
  for pic in $(ls -l $sdir); do
    mv "$pic" "$TARGETROOT/$(basename $sdir)"
  done
done

This should perfectly meet your requirements:

  • Runs on Linux: Yes. Everywhere Bash4+ runs, in fact.
  • Command line: Yes.
  • No GUI, preferably no notifications at all: Exactly. If you wish for notifications, it would be possible, though, using e.g. notify-send.
  • Open Source and gratis: Yes, both.
  • Transfer via USB: Yes. Could do via WiFi if needed, though, if you configure ADB over TCP.
  • Allows to configure paths: It even requires that 😁
4
  • 1
    I had thought about adb pull+rm, but I am a bit worried about deleting files in edge cases. adbfs sounds good, I will try it!
    – Nicolas Raoul
    Jul 19, 2018 at 12:45
  • 1
    I share your concerns. That's why I recommended adbfs and the mv command: source will only be removed when the copy succeeded.
    – Izzy
    Jul 19, 2018 at 13:19
  • A problem with the adbfs approach seems to be that the media is not deleted from the phone (even after a reboot the pictures are still there). Maybe adbfs is read-only?
    – Nicolas Raoul
    Jul 20, 2018 at 13:21
  • @NicolasRaoul what Android version are you on? There indeed was an issue with write access on Android 7+, but that was supposed to be fixed (issue is still open, so you can check). On Android 6 (and below) it works perfectly, read and write.
    – Izzy
    Jul 20, 2018 at 15:45
0

I wrote a tool for this, based on Izzy's answer:

https://github.com/nicolas-raoul/move-files-from-android

It is based on adbfs, mounting the Android devices and then moving all files found in directories.conf.

Open source. Quite fast. Works with Ubuntu 2018.04 and 2019.04, probably others too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.