7

I have a bunch of photos on my Samsung Galaxy Tab running 3.2 which I'd like to copy over USB to my main machine running Linux so I can work on them with GIMP and other power tools. Despite this seeming like a simple and common thing to do, I haven't found any way to do this after hours of googling and experimenting.

Some answers and articles already out there assume the existence of sdcard, which I don't have (AFIK), mention directories named /dcim or /emmc (sp?), involve Windows-only software such as Kies, or are about some specialized problem not relevent here.

I figured I could poke around the Galaxy Tab's file system with adb, but found no place holding .jpg or other image files, which I should have at least 30 or so of. If I knew the path, I could just do an adb pull to get my photos.

If it's possible, I prefer to use adb pull, since it can be automated, but I also wonder how regular folk, the nontechies, get their photos off their tablets. I have read about MTP and that the USB mass storage device way of doing things doesn't work with the Galaxy Tab (or anything Samsung?)

Just to be clear, my photos do exist on the tablet. I can see them all in the Gallery, as a regular end user. I do have the proper USB cable, and adb runs fine.

6

I assume you have Galaxy Tab with Honeycomb and don't have a SD card slot, but have 16/32 GBs of internal storage. In Honeycomb, MTP mode (Windows Media Transfer Protocol) is used instead of USB Mass storage. That's why it's isn't working for you perhaps.

First read what MTP is and why it's being used by OEMs now here. MTP and ICS. Also this Question should be useful - Android Stack Exchange - Can I disable MTP mode and just have a regular USB connection?

Have your tried enabling MTP support for Linux? These are the steps for a Ubuntu distro - Guide To Setup MTP.

Alternatively via using ADB I believe you can access Gallery files in /mnt/sdcard/. The sdcard folder should be there even if you don't have a SD card slot. Camera photos would be in /DCIM folder.

Full steps would be (if anyone needs) -

adb shell
cd /mnt/sdcard/DCIM/

You can check which folders exist here and verify if your Media files are here or not.

  • There is a /mnt but nothing at all inside it. For me, this mythical sdcard directory is as real as unicorns! – DarenW Apr 24 '12 at 15:03
  • Thanks for the pointer to a quick way to browse the device content. :-) It was a quick adb pull later to get what I needed! Thanks! – Norman H Jun 10 '15 at 13:44
1

I wrote a little script to do this for me that deletes files from the device after pulling:

#!/bin/sh
cleanup() {
    [[ -n "$dest" ]] && cd "$OLDPWD" && rmdir --ignore-fail-on-non-empty "$dest"
}
trap cleanup EXIT

DIRS=( /storage/emulated/0/DCIM/Camera
       /storage/emulated/0/Pictures/Office\ Lens )
dest=$(mktemp -d -p .) && cd $dest
echo output directory: $(pwd)
for dir in "${DIRS[@]}"
do
    echo downloading from $dir
    adb shell ls "'$dir'/*.jpg" 2>/dev/null | xargs -I{} -n 1 -d '\n' sh -c 'adb pull -a "$1" && adb shell rm "\"$1\"" && adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d \"file://$1\" || exit 255' -- {} || break
done

The main process is a loop executed once for each directory $dir specified in $DIRS that terminates on the first failure.

The break prevents processing in the event of an error so that the script exits on the first failure.

The loop executes a compound command for each directory listed in $DIRS as $dir. The first piece is straightforward:

ls "'$dir'/*.jpg" 2>/dev/null

It does what it says on the tin - lists all of the JPEG files located at $dir. The 2>/dev/null hides the No such file or directory error message that would otherwise be displayed when there are no such files.

The output of ls is piped into xargs - the arguments set {} as the placeholder, \n as the delimiter and processes files one at a time. The command line used to process each file follows:

sh -c 'adb pull -a "$1" && adb shell rm "\"$1\"" && adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d \"file://$1\" || exit 255' -- {}

Which is itself a compound command of three adb commands executed by a sh shell which is given the file as an argument ($1) specified by its {} placeholder.

The first command downloads the file:

adb pull -a "$1"

If that succeeds then the second command removes the file from the Android device:

adb shell rm "\"$1\""

The extra quoting is necessary so that file names containing white space are properly passed into the adb shell. If that command succeeds then the final command lets the device know the file is gone:

adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d \"file://$1\"

Once again, quoting is applied for adb shell. This step is required to update the images listed in the Gallery app (otherwise they may be cached and still display).

The compound command finishes with exit 255 in the event that any of the adb commands fail. This has special meaning to xargs and causes it to terminate without processing any more files.

This is a quick and dirty script - it could probably be improved but hopefully it's helpful as it is.

0

If you can't find your files easily using ADB on /mnt/sdcard (which as Sameer mentions is where it should be, even if you don't have an external SD card), you might find it easier to use a local file explorer to search for/manage your pics. For many distros (like Ubuntu) you need to manually add a usb identifier for the device in udev after installing ADB.

  • Really? I connected my device via USB an "it just worked"(TM). I'm running Ubuntu 10.4 – CjS May 8 '12 at 11:21
  • I've never seen one connect without doing the manual add yet, myself. Was it a tablet? It might be identifying itself differently over USB than a phone might, or the manufacturer could have tweaked it. – Logos May 8 '12 at 15:25
  • Yes, an Asus TF-101 running 3.2 and 4.0.x. But my phone (LG Optimus One) also connects as long as usb debugging is checked in the settings. – CjS May 9 '12 at 15:08
  • Now that I think about it, the Acer Aconia didn't "just work", so it may be manufacturer dependent. – CjS May 11 '12 at 13:42
0

I don't think the filesystem on Android tabs is universal.

I haven't played with the Galaxy Tab, but on my Asus TF101, the internal storage is at /mnt/sdcard, while on my dad's Acer Iconia, it's /sdcard (IIRC).

From a quick google, it appears that Galaxy Tab photos are stored in /sdcard/DCIM/Camera/ or /Data/DCIM/Camera/ for internal storage or perhaps /sdcard/external_sd/DCIM/Camera/ if using the 'external' sdcard.

I'd look for these three folders using a file manager on your device (or ADB) and then use ADB to pull them as you described once you've found your photos.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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