Downloading Files From an Android via MTP

by intox

I found myself in the mountains of Pennsylvania with no access to the internet, no cell service, and thus no way of downloading any software to help me access files I had on my phone. I tried to SFTP like I usually do, but of course you need to be connected to a network and I had no router to set up a local network with.

I figured I could share wifi from another phone and just FTP locally, but turns out we couldn’t get it to set up a local connection without cell service. These newer androids don’t support anything but MTP and PTP, that is, you cannot mount your phone as a mass storage device. I also found that nothing on my slack setup except some very basic mtp-tools were installed, and I couldn’t find any mtp man pages. Now, I probably wouldn’t use this method otherwise given that I have access to other tools and information on the net, but here’s what I did anyways:

Connect phone to computer and run:





mtp-files > contents.txt

It should output some information about your phone with the first command. The second should output and then give you a bunch of optional inputs. The third should output some info and output a list of files on your phone and corresponding numbers to a file in the directory you’re currently in called “contents.txt”.

Next, open up contents.txt and search for the file you want to download. Probably at the end of the file. Next, to download said files, run:

mtp-connect --getfile FILENUMBER FILENAME

The filenumber is the number in contents.txt before the filename, pretty straightforward. You can also do this with folders, I believe, but instead of –getfile you do –getfolder. There’s also ways of uploading, deleting, and things of that nature.

I don’t think there’s much documentation on this anywhere because there are other ways of mounting via MTP and there are other tools based on MTP-tools or libmtp or whatever it is, but in a pinch this was easy enough to figure out just based on the tools I had.


By: Glenda (Sun Jul 26 05:33:47 EDT 2015)

Is there a fuse mtpfs??!?!

By: Glenda (Fri Feb 5 19:33:19 EST 2016)
Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.6

Is this normal?

PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
Usage: connect <command1> <command2>
Commands: --delete [filename]
--sendfile [source] [destination]
--sendtrack [source] [destination]
--getfile [source] [destination]
--newfolder [foldername]


By: Glenda (Fri Feb 5 19:34:00 EST 2016)
ok it works thanks <3

By: Glenda (Fri Feb 5 19:54:28 EST 2016)
This was buggy and slow, and didn't work for me, ended up using ADB which was still slow but less buggy in the end because it actually worked.

Photos and shit were in /storage/sdcard0/DCIM (not an actual sdcard? It's the device's internal stuff)