Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open folder on portable device with batch file

  1. General goal: create a desktop shortcut to a folder buried the file structure of my phone's SD card (connected via USB). Note, this is on a work computer, so I can't do anything to crazy. I tried using normal shortcuts to no avail, so I decided to try using a batch if I can't use a shortcut. If using a shortcut is possible or there is a better option than a batch let me know.
  2. Specific question: How can I open a folder using a batch file? I can manually open explorer, paste the address into the bar and go there, so there should be a way to mimic this, but so far my attempts have been unsuccessful.

Attempts:

%SystemRoot%\explorer.exe "Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch\"
explorer Computer/My S4/Phone/Android/data/com.dropbox.android/files/scratch
start "" "Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch\"
start Computer\My S4\Phone\Android\data\com.dropbox.android\files\scratch
like image 659
Kalev Maricq Avatar asked Sep 06 '25 03:09

Kalev Maricq


2 Answers

This is an addition to Andry's answer:

It can be very complicated to get the whole path to an MTP folder like ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}

To get the path do the following:

  1. In Windows Explorer select the folder on the MTP device you want to get the path of.
  2. Open it's context menu and select Copy
  3. Open in Explorer a folder on your PC, open the context menu on a free area and select Paste Shortcut
  4. Now we need a tool that can read .lnk files. I have used the tool LECmd. Execute LECmd.exe -f <path to the .lnk file created in step 3>.

You will get a lot of content printed to the console. The interesting part is the Parsing Path next to the end.

In my case it was ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\SID-{10001,,21003612160}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}

Now we are close, unfortunately the path shown above can not be used because it contains an invalid part: \SID-{10001,,21003612160}. Remove that part and you can open the explorer in that MTP folder using

start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_03de&pid_21e7&mi_00#6&a5ebb37&1&0000#{6ac27878-a6fc-2155-ea85-f98f491d4f33}\{E4FC4EA5-FFFF-FFFF-0000-000000000000}"

like image 194
Robert Avatar answered Sep 07 '25 22:09

Robert


There is a way to open an MTP device folder directly in the Windows Explorer window on Windows 7 x64.

Here is steps:

  1. Open Windows Explorer with the My Computer folder, for example:

    • start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
    • start "" "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
    • explorer "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
    • explorer "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"

    The complete list of GUIDs you can find on the internet, for example: https://www.tenforums.com/tutorials/3123-clsid-key-guid-shortcuts-list-windows-10-a.html

  2. Attach the MTP device and enable File Transfer mode in the device. It must be shown in the My Computer window as a portable device entry.

  3. Drag and Drop the MTP device entry icon to the Desktop.

  4. Open any notepad, for the instance, Windows notepad: Win+R -> notepad

  5. Drag and drop the desktop icon into notepad window. At the end of the notepad text would be something like: ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33} (spaces removed). You can cleanup the spaces between characters by copy the string into another instance of the notepad and replace them through the Ctrl+H to nothing.

  6. Now you can open the MTP device folder directly: start "" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\<your-local-path-to-folder>"

There is a wait timeout, so the Windows Explorer window might not open immediately.

To generate a shortcut to target folder you can use make_shortcut.vbs script from here: Source code

For example:

>
make_shortcut.vbs -obj myphonecamera.lnk "shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\\?\usb#vid_0e8d&pid_201d&mi_00#7&1084e14&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\SD-card Samsung\DCIM\Camera"

Now you can click myphonecamera.lnk to open the folder or use the Windows Explorer:

>
explorer myphonecamera.lnk
like image 44
Andry Avatar answered Sep 07 '25 21:09

Andry