Tool Trouble. How to preview tool output?

v2.58

I'm exploring a feature of MP3tag - tools. So I would like to create a tool that goes to www.elyrics.net and show me the list of songs from an artist (lyrics that are available)

So I need to accomplish the following tasks:

  1. convert the artist to lowercase
  2. remove leading "the+space"
  3. get first character of artist
  4. convert spaces within artist to "-"
  5. create a URL (hyperlink)
  6. use the web browser of my choice to fetch the webpage and display it.

With these tasks in mind I did the following:
Selected Menu TOOLS|OPTIONS|TOOLS (left column)|right side clicked icon NEW
NAME: opera-elyrics-artist
PATH:C:\Program Files\Opera\opera.exe
PARAMETER: http://www.elyrics.net/song/$left($regexp($lower(%artist%),^the\s+,""),1)/$replace($regexp($lower(%artist%),^the\s+,""), ,-)-lyrics.html

The goal of this parameter is to create the following URL.

http://www.elyrics.net/song/m/marshall-tucker-band-lyrics.html

But the value of %artist% = "The Marshall Tucker Band"

Of course this attempt at using my new tool failed to create the desired URL. The website produced a 404 ERROR (Page Not Found).

My questions are...

  1. Is there a way to preview any of the results of any of the elements that I constructed in my parameter?
  2. Can I create a tool to send the output to Notepad (or some other text viewer) for debugging purposes?
  3. What did I do wrong in constructing the PARAMETER? I'm not seeing syntax error.

Yes. You can use the coverter Tag-Tag to see a preview of your format string.

Some examples ...

Wikipedia Album '"http://www.google.de/search?q=site%3Awikipedia.org+'$regexp($regexp($regexp($lower($trim(%ALBUM%)),'[^a-z 0-9]',),'\b(?:and|und)\b',),'\s+','+')'"' Wikipedia Artist '"http://www.google.de/search?q=site%3Awikipedia.org+'$regexp($regexp($regexp($lower($trim(%ARTIST%)),'[^a-z 0-9]',),'\b(?:and|und)\b',),'\s+','+')'"' Google Artist '"http://www.google.com/search?as_q='$replace(%ARTIST%,' ','+','&','%26','?','%3F')'&as_qdr=all&num=20"' Google Images '"http://www.google.com/images?as_q='$replace(%ARTIST%' '%TITLE%,' ','+','&','%26','?','%3F')'"' Google Lyrics '"http://www.google.de/search?as_q='$replace(%ARTIST%' '%TITLE%' Lyrics',' ','+','&','%26','?','%3F')'&as_qdr=all&num=20"' GermanCharts '"http://germancharts.com/search.asp?cat=s&artist='%ARTIST%'&artist_search=starts&title='%TITLE%'&title_search=starts"' elyrics.net '"http://www.elyrics.net/song/'$regexp(%ARTIST%,'^(?:The)?\s*(.).+?\s*$','\L$1')'/'$regexp($regexp(%ARTIST%,'^(?:The)?\s*(.+?)\s*$','\L$1'),'\s','-')'-lyrics.html"' ... or ... '"http://www.elyrics.net/song/'$regexp($regexp(%ARTIST%'###'%ARTIST%,'^(?:The)?\s*(.).+?\s*###(?:The)?\s*(.+?)\s*$','\L$1/$2'),'\s','-')'-lyrics.html"'

DD.20140410.1318.CEST

Create a .BAT file with this line:

echo %1 | clip

Use the path to the .BAT file.
The parameter is the format string and the results will be written to the clipboard, which you can paste in Notepad.

The double quotes cause the problem.
Try this:
PARAMETER: http://www.elyrics.net/song/$left($regexp($lower(%artist%),^the\s+,),1)/$replace($regexp($lower(%artist%),^the\s+,), ,-)-lyrics.html

Thank you. This answers my question regarding how to preview the construction of a complicated script.

For the benefit of others, I did the following:
Selected MENU CONVERT| Tag-Tag
Field: COMMENT (I chose this tag to prevent overwriting existing data)
Format String: (I copied and pasted my script into this box)
And instantly below it displays the output. I didn't even have to click the PREVIEW button.

Fantastic.
Question Answered.

DetLevD Kudos. Thank for the examples. I see the error of my ways.
Problem solved.

For the benefit of others, this is how I corrected my script and it works in a tool.

'"http://www.elyrics.net/song/'$left($regexp($lower(%artist%),'^the\s+','$1'),1)'/'$replace($regexp($lower(%artist%),'^the\s+','$1'), ,-)'-lyrics.html"'

Of course, I could have used the example provided verbatum (elegant coding), but I'm learning how to create tools. So I tinkered with my original script and got it to work as expected.

Lastly, I'd like to learn more. Where can I find more information regarding the syntax because I have another tool script that works without double-encapsulating it within ' " ..... " ' and without encapsulating the function. Here it is:

https://en.wikipedia.org/w/index.php?search=$replace(%artist%, ,+)

So of course I tried to execute the elyrics script without encapsulation and it failed. So I'm unclear as to when encapsulation is required.

Just in a nutshell! 1. Rules for the system command line: In general a commandline (without optional switches) is structured like ... "P:\Program Files\test.exe" abc 123 filename.ext The space character is used to separate the items. "P:\Program Files\test.exe" abc 123 filename.ext If one parameter contains one or more space characters, then the parameter string has to be enclosed into double quotes. "P:\Program Files\test.exe" "a b c" 123 "file name.ext" ==> (three parameters) "P:\Program Files\test.exe" "a b c 123 file name.ext" ==> (one parameter) "P:\Program Files\test.exe" a b c 123 file name.ext ==> (six parameters) 2. Rules for the Mp3tag Tools feature: The Mp3tag "Options/Tools" edit field "parameters" expects respectively accepts a Mp3tag format string, which should create a valid commandline for the called program. '"'%ARTIST%'" '$num(%TRACK%,3)' "'%_filename_ext%'"' param1 param2 param3 '"'%ARTIST%' '$num(%TRACK%,3)' '%_filename_ext%'"' param1

This is quirky regexp syntax ... because there is no $1 group referenced in the regular expression, the $1 referrer is empty resp. does not exist, therefore you can leave the replacement part of the regexp empty.

'"http://www.elyrics.net/song/'$left($regexp($lower(%ARTIST%),'^the\s+',),1)'/'$replace($regexp($lower(%ARTIST%),'^the\s+',),' ','-')'-lyrics.html"'

DD.20140410.2009.CEST

Thank you for sharing these rules and your help. I'm very excited to explore this powerful feature. This is going to be fun.

One last question, is there a character limit to the length of the PARAMETER?

I'm glad you brought it up. I thought it was strange. But when I looked at the examples I saw that they were used. So I used them too.

BTW, here is an improved script which accounts for Artists that begin with a digit (0-9):
'"http://www.elyrics.net/song/'$if($isdigit($left($regexp($lower(%artist%),'^the\s+',),1)),'0-9',$left($regexp($lower(%artist%),'^the\s+',),1))'/'$replace($regexp($lower(%artist%),'^the\s+',), ,-)'-lyrics.html"'

There is a MS article with old wisdoms about the command-line string limitation.
So we should hope, and rely on, that Florian has also reserved enough space.
(english) https://support.microsoft.com/en-us/kb/830473
(german) https://support.microsoft.com/de-de/kb/830473

DD.20140411.2114.CEST