How do I access MTP devices on the command line in Windows?

72

20

Most MTP (Media Transfer Protocol) devices show up in Windows File Explorer under their device name or a GUID, but they don't have a drive letter assigned.

How can I access the files on such devices from the command line? Using either cmd.exe or PowerShell.

Peter Hahndorf

Posted 2011-12-20T19:52:05.433

Reputation: 10 677

@MarkBooth I tried the WebDAV server but it seems most of the files I transfer are corrupt (over 90%)... – Michael – 2016-12-24T18:20:29.393

Other solution for Android going the other way round, tweaking the connected device: 1, 2, 3.

– Frédéric – 2017-07-05T11:08:43.850

2

The fact that the Linux MTP compatible implementations such as gphoto2 have a way to script uploading suggests that this should be possible on Windows somehow, assuming that Windows Media Player doesn't somehow block any other software from accessing the USB MTP interface... I too would like to know if this is possible.

– Mokubai – 2011-12-20T22:00:03.710

2

I gave up trying to find a solution for this with my Android MTP device and ended up installing a WebDAV server on my device. This could be mounted as a network drive, albeit slowly.

– Mark Booth – 2012-10-14T13:25:46.073

WebDAV...ugh... That's painful. It would work decently enough though. It's...surprising...to me that Windows can't seem to manage what Linux does out of box effortlessly. Oh, well. – Svartalf – 2014-05-09T19:57:39.747

Answers

29

Unfortunately, APIs exposed by MTP are very different from a normal filesystem APIs. Therefore exposing MTP device as a read/write filesystem is not possible. The main reason:

Wikipedia says:

Neither the MTP nor the PTP standards allow for direct modification of objects. Instead, modified objects must be reuploaded in their entirety, which can take a long time for large objects. With PTP/MTP, the file size must be known at the opening stage.

Your common file copy program just opens a source and a target file, and copies data in chunks from the source file to the target. This won't work with MTP, since you need to use MTP special functions, and generic filesystem primitives (read, seek, write) are not available.

There are also other limitations. For example, the number of files that can be read or written simultaneously on an MTP device is severely limited. The device simply does not behave like a filesystem.

I suppose read-only filesystem driver for an MTP device might be possible, but because of the problems outlined above, it will be of very little use, so nobody bothered to create it.

haimg

Posted 2011-12-20T19:52:05.433

Reputation: 19 503

4

The read-only filesystem driver seems to exist now: http://ptpdrive.com/

– Arne de Bruijn – 2013-09-12T12:25:59.163

5Actually, it's not "not possible". When you consider that I've got gphotofs and mtpfs as FUSE filesystems on Linux that're COMPLETELY Read/Write- its' quite possible to accomplish this as a "drive letter" under Windows...they've just not made it available or easy. – Svartalf – 2014-05-09T19:57:04.853

3

There is a proprietary (but still nice) program: MTP Drive (https://www.mtpdrive.com/) which allows you to "mount" MTP devices as drives in Windows. With some reasonable limitations it does the great job!

barbalion

Posted 2011-12-20T19:52:05.433

Reputation: 41

1>

  • Can that synthetic MTP drive be feed to a common drive data recovery tools like EASEUS/Recuva/R-Studio and data be recovered effeciently?
  • Can I use robocopy/other fast data transfer tools to transfer data from that drive to windows native drives(C/D etc.) efficiently?
  • < – SIslam – 2018-08-27T13:44:52.270

    1

    You may be able to cobble something together with the MTP porting kit's MTPMon.

    Alternatively, PowerShell can create COM objects and call their methods, so you may be able to use the APIs that Windows Explorer is using (for example, GetDeviceInfo() and GetObjectInfo()).

    Shea

    Posted 2011-12-20T19:52:05.433

    Reputation: 119