Utility to pull the last n
number of photos from an Android device.
- An Android device
- Android Debug Bridge (
adb
) installed bash
On Ubuntu installing adb
should be pretty easy: sudo apt install android-tools-adb
.
More data on this tool is in the official documentation.
adb_photo_pull number
The only argument is number
and should be an integer.
Copy adb_photo_pull.sh
in /usr/local/bin/
to call it form anywhere.
NOTE: Edit the two variables photo_dir
and out_dir
according to your needs.
With Ubuntu 18.04 came out Bug #1792085.
In short, mtp
connection become very slow when browsing a folder
with lots of files like DCIM/Camera
.
I do not have any kind of sync for photos enabled on my phone, neither Google Photos or Samsung Sync or similar.
Sometimes it happens that I have to take a couple of pictures and put them
on my laptop to edit or to hand them to a friend on a USB stick
and here comes the pain: mtp
too slow, bluetooth
too slow...
how to take this photos out of the phone?!?
I found this interesting article and I decided to give it a try: it really works!
What is a bit annoying is to spawn an adb shell
to find out the names
of the photos to then adb pull
the desired file.
What I need to do is just something like adb pull [last n photos]
so I wrote a rough bash script to do so.
Assumption(s):
- Filenames of photos are in chronological order
You have to enable Developer mode
on your phone by tapping multiple times
on the Build Number
(How to get there differs between Android versions,
just do a quick search on the Internet),
then go to Developer options
and toggle USB debugging
on.
You may find this article useful.
Connect the phone to your computer with the USB cable and, when prompted (on the phone) allow the connection.
I never connect my phone to untrusted devices, I charge the phone with my power adapter, not at public charge stations where you connect just the USB cable.
Enabling USB debugging may lead to security related issues (i.e. if you lose your phone), keep this in mind.