Downloading Files From an Android via MTP
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.