Author Topic: Use of quotes in external tool parameters  (Read 1573 times)

mrbenn

  • Full Member
  • ***
  • Posts: 168
I want to open windows terminal and pass the full path of the selected file when clicked.

An example of the final, vanilla command I would want to run is:

Quote
wt -d "M:\Folder\With\Album" -Command beet import .

This would open terminal already CD'd to that folder, then run the command without having to invoke a script. As you can see there are quotes around the folder path.

Whenever I enclose the <Path> field in quotes, it sends the command of
Quote
wt -d <Path> (etc...)
not the value. I cannot work out how to escape the quotes in MusicBee - I have used
Quote
-d '"'<Path>'"'
and a number of other combinations but cannot format the command correctly.

I cannot use single ' to enclose the path since if that character is in a folder name it trips up - the character " cannot be used in a file or folder name in Windows, but ' can.

TL:DR - how do I encapsulate a field in double " quotes when the command to be run is generated without MusicBee interpreting it as a string literal, rather than variable.

Zak

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 2459
I don't have Windows Terminal installed to do a direct comparison, but I haven't had any problems testing with the normal windows Command Line.

If I create an External Tool entry for cmd and use these parameters:

Code
/K cd /d "<Path>" && echo "<Path>" && echo <Path>  && echo "<URL>" && echo <URL> && ffprobe -i "<URL>" 
everything works as expected. This opens a command window in the file's folder, displays its folder and path and opens it in the ffprobe command line program.
"M:\Music\B\Beatles, The\1964.1 - A Hard Day's Night\"
M:\Music\B\Beatles, The\1964.1 - A Hard Day's Night\
"M:\Music\B\Beatles, The\1964.1 - A Hard Day's Night\01 - A Hard Day's Night.flac"
M:\Music\B\Beatles, The\1964.1 - A Hard Day's Night\01 - A Hard Day's Night.flac

The output suggests MusicBee just passes the folder and files path as is, without any special quote processing.
If I enclose the path in quotes they're included in the output. If I leave them off, they're not.
I don't see MusicBee treating "<Path>" as a literal string.

Probably a silly question, but you are putting the parameters in the parameters field, not with the application path?
Bee excellent to each other...

mrbenn

  • Full Member
  • ***
  • Posts: 168
Thanks for the suggestion Zak. I'll do some testing later and get some screen shots of what I'm seeing.

edit: yes, "wt" is in the middle column, and everything else is in the right hand column in the musicbee settings panel.
Last Edit: September 11, 2021, 06:34:16 PM by mrbenn

mrbenn

  • Full Member
  • ***
  • Posts: 168
After some experimenting, I have gotten
Code
/K cd /d "<Path>" && wt -p "PowerShell" -d .  beet import . 
to work as intended.

Things I found: it does not work if I call pwsh.exe or wt.exe and attempt the same command - it *has* to go via cmd.exe
 I think this is down to our old frenemy " \ " and how powershell escapes things like spaces.

Also, the issues with quotes altering the output in the Template Editor Preview - the output string that is sent by MusicBee is correct, but previewing it shows otherwise.