1

I am working on a script that partially automates backing up contents of an MTP device. Before continuing, I am trying to verify that the relevant folders can be accessed, by adding a line that opens a folder in nemo. This is the script:

#!/bin/bash

echo "mtp://[usb:[BUS],[DEVICE]]"
echo -n "Enter BUS: "
read BUS
echo -n "Enter DEVICE: "
read DEVICE
nemo /run/user/1000/gvfs/mtp:host=%5Busb%3A$BUS%2C$DEVICE%5D/Internal%20shared%20storage/

The first "echo"-line is just for user reference.

$BUS and $DEVICE are correctly substituted with the entered values, resulting in the correct path for the root of the MTP device, but the following folder isn't interpreted correctly, as I get the following error message:

"Could not find "mtp://[usb:002,036]/Internal%2520shared%2520storage".

Please check the spelling and try again.

[OK]"

Where does the twice added "25" come from and how can I remedy this so the script opens the correct path in nemo?

closed as off-topic by Jeff Schaller, Rui F Ribeiro, Anthon, Stephen Rauch, Kusalananda Aug 14 '17 at 6:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, Rui F Ribeiro, Anthon, Stephen Rauch, Kusalananda
If this question can be reworded to fit the rules in the help center, please edit the question.

  • isn't 25 hexadecimal ascii code for % ? I expect %20 turn to %2520 – Archemar Aug 6 '17 at 9:15
  • 2
    try quoting and use space. – Archemar Aug 6 '17 at 9:17
  • @Archemar Where should I place the quotes and the space? I am an absolute beginner when it comes to shell scripting. – user245225 Aug 6 '17 at 9:26
  • 1
    nemo "/run/user/1000/gvfs/mtp:host=%5Busb%3A$BUS%2C$DEVICE%5D/Internal shared storage/" – Archemar Aug 6 '17 at 9:41
  • 1
    @Archemar Edited comment, got ninja'd. Your suggestion works. Thank you! – user245225 Aug 6 '17 at 9:45
1

Archemar's suggestion of substituting %20 with a space and using double quote around the path string remedied my problem and results in the folder being opened correctly.