[WS] iTunes


Hm, no. I did not build a limit into the script. There is a limit for search results which is 200, but not for songs within a release.
Maybe that's some technical limit at itunes, like you have to get to a seconcd page at the 201st song. I don't know. If you post the link to the itunes pages of the 316 song release, I will have a look at the problem


Sorry, I oversaw your question since you had two post i a row.

A little test gave me positve results. I is actually possible.
And, I just saw that the script in the starting post still has only 100x100 covers, personally I use 600x600 as cduve gave instructions over a year ago.:
[WS] iTunes
The same works for 1200x1200, though I don't know if this cover size is available for all releases. If not, you will parsing results without covers. If this happens, please leave a note here.
Do you know which cover sizes itunes provides?

Time for an update of the script. I hope to fix poster's 200 song problem, after that will be a good time for an update.


Thank you pone that you have a look.
It's this edition:

I noticed that on the website itunes lists the songs with a seperate numbering for every CD of the box.
Is there a possibility to get this extra information in the websearch results?
Dano's Amazon-MP3 scripts had this information most of the time but they don't work anymore.


Actually I have built this limit into the script. It's in line 37:
say "&entity=song&limit=200"

But it looks like itunes forces API users to set a limt and the maximum is 200:
So I'm afraid, I see no way to change that.

I can add discnumber and tracknumber to the script. Maybe at the update. Or I will build an optional code into the script, which can be activated by editing the script.
Until that, you can make my beta tester:

add this to the TRACK LOOP:

outputto "TRACK TEMP"

sayregexp "(?<=\"trackNumber\":)\d+?(?=\D)" ", " "}"
say "|"

outputto "DISCNUMBER"
sayregexp "(?<=\"discNumber\":)\d+?(?=\D)" ", " "}"
say "|"</i>

and this at the end of the script:

outputto "TITLE"
sayoutput "TRACKS"

outputto "TRACK"
sayoutput "TRACK TEMP"

please let me know if you are experiencing any troubles


I found this code before asking here and realized that changing the 200 to another value made no difference. So Itunes is obviously setting the limit anyway.

Do you see any workaround to get the informations for the tracks 201 - ...?
Is there a possibility for coding in a seperate script to skip the first 200 and start with 201?

Many thanks for your effort to make your scripts even better.
I made somes tests with your code-changes.

There is a shift-problem qith these consequences:
The track-numbers start with "2" instead of "1". Therefore the last track gets unnumbered in tracks and discnumbers. The second CD tracknumbers and disknumbers start with the last track of the first CD and so on.

I am sure you are able to fix this. :wink:


I found a solution of this problem myself.

I first had added

outputto "TRACK TEMP"
sayregexp "(?<=\"trackNumber\":)\d+?(?=\D)" ", " "}"
say "|"

outputto "DISCNUMBER"
sayregexp "(?<=\"discNumber\":)\d+?(?=\D)" ", " "}"
say "|"

at the end of the track loop.
I now added it in the track loop in the beginning after

joinuntil "\"}"
replace "\\\"" "&quot;"

and it works as intended.

What would I have to change to get these results:

  1. Tracknumbers like 101/15 (101=track 1 of first CD; 15=totaltracks per CD) if there is a CD-set.

  2. Disnumbers like 1/3 (Disk 1 of 3 disks)


I found the solution for 2.

outputto "DISCNUMBER"
sayregexp "(?<=\"discNumber\":)\d+?(?=\D)" ", " "}"
say "/"
sayregexp "(?<=\"discCount\":)\d+?(?=\D)" ", " "}"
say "|"

but no solution for 1, because I dont't know how to format the result for trackNumber with 2 or 3 digits and leaqding zeros.


This line adds a leading zero to all single digit tracknumber. Put it at the top of the track loop, after the first two lines with the "joinuntil" and "replace" commands:

regexpreplace ""trackNumber":(\d)(\D)" ""trackNumber":0$1$2"

after that, add the red lines to the track number section in the track loop:

outputto "TRACK TEMP"

sayregexp "(?<=\"discNumber\":)\d+?(?=\D)" ", " "}"
sayregexp "(?<=\"trackNumber\":)\d+?(?=\D)" ", " "}"
say "/"
sayregexp "(?<=\"trackCount\":)\d+?(?=\D)" ", " "}"    <!--colorc--></span><!--/colorc-->
say "|"</i>

(the same trick you did at discnumber)

No. You should think the should be something to do that. But I can't find anything. Google search in other forums also didn't bring much help.


Thank you pone.
Your suggestions work as intended.

Please be so kind and tell me what this piece of code does, becaus I like to lean and understand what I am doing:

regexpreplace "\"trackNumber\":(\d)(\D)" "\"trackNumber\":0$1$2"

So I have to tag 116 files manually because I cound not find another source that delivers this box-set.
Thank God that there are not so many box-sets which have more than 2000 songs. :rolleyes:


This adds a zero to single digit number (1-9)

in regular expressions:

\d is a digit, a single number 0-9

\D is every other character which is no digit.
() groups any sequence of characters which is inside the parenthesis together. This group can be recalled in the second part or the regexreplace command with $n ($1 and $2 in this case)


\d\D is a digit which is NOT followed by another digit, so it's 1, 2, 3,... but not 10, 11, 12


this adds 0 in front of the single digit, than puts the single digit and whaterver followed after it as it was before
in cases of two digit numbers (10, 11, 12, ...) the command does nothing because the regular expression \"trackNumber\":\d\D can not be found.

thinking about that command again, I see I could have done it more simple:
regexpreplace ""trackNumber":(\d\D)" ""trackNumber":0$1"


Hi! I'm a total newbie to this stuff, and was helpfully pointed to your script from another forum. I have it installed and running fine, but I'm trying to get it to tag over 6000 of my songs. Is there any way to make it tag them all automatically, or am I going to be going through each one individually doing this? Thanks in advance!


Mp3tag has no way to tag a complete collection automatically. There are some media players which have such functions, but usually that doesn't go without errors.

With the different web scripts for Mp3tag you don't have to go through each song individually, but through each release (album, compilation, single, EP, box-set, ...).
If your collection consists mainly of full releases, you will have quick success, but if you have mainly single tracks of different origin in huge folders, the web scripts won't be much help.


Thanks for the quick answer! I have a healthy mix of both, but mostly full releases, so it's going swifter than it normally would. This is some great work!

Do you know offhand the reason for some albums coming up without matches? I can search iTunes myself and find the album on there, but the script won't find it (for example, The Lego Movie Soundtrack). I feel like I'm doing something wrong.

Also, do you know offhand is there's any way to deal with duplicate files in this program? Recovering from catastrophic data loss gave me a fair amount of duplicates that are mucking up some of the process.


The release for search without matches is most probably because the script searches only the US itunes catalog.
To change that, open the .src file with a text editor and change two lines at the top of the script as shown here:
[WS] iTunes

The example has GB for Great Britain. See this list at wikipedia for the country code you want to choose:

For duplicates, search the forum. there have been several discussions how to archieve this best. But no solution which works for everyone. Mainly it depends what you are consicering a dublicate. And there is no way Mp3tag gives you a quick list or something. I involves some complicated export scripts to get such an list. Personally I never went through this.
But as I said: search the forum for "remove duplicates" or "find duplicates"


at UK catalog not find (changed GB)
https://itunes.apple.com/gb/album/addicted-...try/id618445065 (69 Songs)
change lines at script example RU script find it
https://itunes.apple.com/ru/album/addicted-...try/id618494502 (26 Songs)


Hi Pone,

Just spotted a little bug.

On release https://itunes.apple.com/gb/album/sawdust/id267916280 where there is tracks such as Sam's Town (Live from "Abbey Road") the script stopped at the first " to only leave Sam's Town (Live from


outputto "TRACKS"
        replace "[" "("
        replace "]" ")"
        sayregexp "(?<=\"trackCensoredName\":\").+?(?=\")" ", " "}"
        #sayregexp "(?<=\"trackName\":\").+?(?=\")" ", " "}"
        say "|"


outputto "TRACKS"
        replace "[" "("
        replace "]" ")"
        sayregexp "(?<=\"trackCensoredName\":\").+?(?=\",)" ", " "}"
        #sayregexp "(?<=\"trackName\":\").+?(?=\",)" ", " "}"
        say "|"


replace "[" "("
replace "]" ")"

I've added those myself to replace the [ with ( and ] with )


Question on formatting. I want to populate the ReleaseDate field, and I have:

sayregexp "(?<="releasedate":")\d\d\d\d(?=.)" ", " "}"

But it's outputting something like "2003-09-23T07:00:00Z" .. How can I change that to just show "2003-09-23"?

Also, the Publisher field is still putting a "β„—" in, how can i remove that? i.e. "β„— SONY BMG MUSIC ENTERTAINMENT" to just "SONY BMG MUSIC ENTERTAINMENT"



Do not modify the code of the src file, because in this case it delivers correct data.
Do your personally motivated modifications after receiving the correct data by a following Mp3tag action.

Action .....: Format value Field ......: RELEASEDATE Formatstring: $left(%RELEASEDATE%,10) Action .....: Format value Field ......: PUBLISHER Formatstring: $cutLeft(%PUBLISHER%,2)

... or ...

Formatstring: $regexp(%PUBLISHER%,'^β„— ',)

... or ...

Formatstring: $if($eql($left(%PUBLISHER%,2),'β„— '),$cutLeft(%PUBLISHER%,2),%PUBLISHER%)



Thanks DevletD. Also, how can I remove 4 numbers from a string. I.e. "1998 BMG Int." should be "BMG Int.". The numbers aren't always at the beginning either.


Action .....: Format value Field ......: AnyTagField Formatstring: $trimLeft(%AnyTagField%,'0123456789 ')

... or ...

Formatstring: $regexp(%AnyTagField%,'^\d\d\d\d\s',)