Have a current project where I'm trying to figure out a way to copy files(a video) from a MTP device over USB.

From the wiki I discover there is an open-source implementation called libmtp. Has anyone reading this used this? Any examples, tutorials? I'd prefer to run Ubuntu with MATE.

Unix-like systems A free and open-source implementation of the Media Transfer Protocol is available as libmtp.This library incorporates product and device IDs from many sources, and is commonly used in other software for MTP support.

  • Welcome to U&L , what is your Ubuntu version?
    – GAD3R
    Dec 7 '16 at 12:33
  • Note, there is also a fuse filesystem jmtpfs which allows you simple access to the files. There may also be a gnome plugin to handle mtp devices automatically.
    – meuh
    Dec 7 '16 at 15:53

You should install the required packages:

sudo apt-get install libmtp-dev mtp-tools mtpfs

Connect your device then run mtp-detect, this command will detect and give you some information about your device.

Run mtp-connect then mtp-folders to display your folders with their ID

the mtp-files will display your files/folders with their ID

to create a list file run:

mtp-files > file_list.txt

Use the command mtp-getfile to copy file from your device to your computer , there is an example from debian wiki:

file_list.txt will now contain entries like this:

File ID: 81
Filename: WP_20161029_16_26_49_Pro.jpg
File size 936160 (0x00000000000E48E0) bytes
Parent ID: 12
Storage ID: 0x00010001
Filetype: JPEG file

where "Parent ID" is something like the folder where the file resides on the smartphone. So you'll want to do something like this to get that particular file:

mkdir "12"
mtp-getfile "81" "12/WP_20161029_16_26_49_Pro.jpg"
  • My one remaining issue is how to reset the file ID since every time I delete the file the ID seems to increment by 1. I need the file ID to remain consistent
    – Bachalo
    Dec 8 '16 at 20:41
  • 1
    GAD3R THANKS!!! So even though Ubuntu natively supports mounting of MTP devices I assume I need these mtp libraries installed in order to issue these custom mtp commands for copying files. Am I correct?
    – Bachalo
    Dec 8 '16 at 20:41
  • @eco_bach correct , did you need an easy way to access your files using the file manager?
    – GAD3R
    Dec 8 '16 at 21:04
  • need to script series of commands to copy a single video file. One remaining issue, as mentioned, is resetting the file ID after each copy and deletion
    – Bachalo
    Dec 8 '16 at 21:22

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.