Unique Album Category ID

Hi everyone!

I have been working on getting my script up and running , but cant seem to figure out how to give an album an unique ID number.

The script i have so far:

$loop(%_folderpath%)%title%;$ifgreater($strstr($lower($get(memdirectory)),$lower(%_directory%)),0,test($get(memcounter)),$put(memcounter,%_counter%));$puts(memdirectory,%_directory%);

I use $strstr($lower($get(memdirectory)),$lower(%_directory%)) to compare the current directory with the previous directory (memdirectory) and determine if this is true (1) or untrue (0).

I cannot figure this out and have been working 6 hours on it......

This is what i would like to accomplish, but i guess i am just to stupid to figure it out...

:flushed:

Hi 'necrosis', please can you elaborate what you want to achieve?
What it the reason and what is the goal of your scripting efforts?
Do you need a simple running counter number per album in a small set of albums?
Do you need a worlwide everlasting unique id (GUID) per album?

DD.20110529.1032.CEST

Hi DetlevD

Thank you for your quick response. Because i have so many music, I want to organize and import my complete mp3 collection within a webbased collection tool. Then i want to link this to (for example XBMC), and listen to my music when en where i want.

For this to work i need to create a CateroryID and a ProductID (Those are just the field names the tool uses).

Please take a look at my screenshot, where I circled the red parts in what i despreately try to achieve:

The script needs to generate, for each directory (Albums) and sub directory's, an unique CategoryID number (not need to be worldwide unique, just within the tool). Within these directory's (CategoryID) are MP3 songs. These need to get an unique ProductID according to the CategoryID. My idea to keep it simple is to just append *.1, *.2 etc..

So for example my screenshot. The first album from the top gets an unique CatalogID numer 1 and a unique ProductID for song 1 => 1.1 and song2 =>1.2

I hope this makes things more clear?

Thank you for all your help, as i cant seem to figure things out!

As I understand the situation ...

  • You speak of CatalogID, CategoryID, ProductID, so CatalogID and CategoryID are used as synonyms?
  • Does the CategoryID have the importance of Genre or other musical classification? Or is it in your case of application just the same as the folderpath?
  • The ProductID is needed per track? You want to create the PRoductID simply by appending a running number to the CategoryID?
  • Does it be true, that all IDs are not visible to the user, must not be human readable, and are only used internally by the database?

I recommend to use a GUID as ProductID per track and a GUID per Album as CategoryID.
GUIDs can be created rather easy.
See also ...
Cover Bilder exportieren - importieren
Once the GUID list file has been created, the converter Textfile - Tag can import the GUIDs into the tracks.

If you want to create your own running number based routine, then you may play with the following MTE export script to understand how to code a $loop() ... $loopend() structure and how to use %_counter% placeholder.
Be aware that the Mp3tag Export Scripting Language does not support to $get() a $put() variable within a loop, which has been defined outside of the loop.

$filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.Export.txt',ANSI) $loop(%_folderpath%,1)$loopend()'1: All FolderCount = '%_max_counter% $loop(%_path%)$loopend()'2: All FileCount = '%_max_counter% $repeat('=',50) $loop(%_folderpath%,1) '3: FolderNumber = '%_counter% '4: FolderPath = '%_folderpath% $loop(%_path%)$loopend()'5: FileCount = '%_max_counter% $loop(%_path%) '6: FileNumber = '%_counter% '7: FilePath = '%_path% $loopend()$repeat('-',50) $loopend()

DD.20110529.1637.CEST

Wow!! Thank you for your response, this helped me a great deal in getting me going :slight_smile:

Is it also possible to get the CATEGORYID (see screenshot) within every row?

Now you first loop the CATEGORYID and then loop the PRODUCTID. I tried again for one day now to get the CATEGORYID listed in the same row as the PRODUCTID.

The output right now is like this:

1: All FolderCount = 7
2: All FileCount = 20

3: FolderNumber = 1
4: FolderPath = \\Africa_HiTech-Out_In_The_Streets-(WAP315DV)-WEB-2011-KOUALA
5: FileCount = 1

6: FileNumber = 1
7: FilePath = \\Africa_HiTech-Out_In_The_Streets-(WAP315DV)-WEB-2011-KOUALA\01-africa_hitech-out_in_the_streets-kouala.mp3

3: FolderNumber = 2
4: FolderPath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320
5: FileCount = 2

6: FileNumber = 1
7: FilePath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320\01-appleblim_and_october-ny_fizzzzz.mp3

6: FileNumber = 2
7: FilePath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320\02-appleblim_and_october-fountains_of_paradise.mp3

But what i try to achieve is

1: All FolderCount = 7
2: All FileCount = 20

3: FolderNumber = 1
4: FolderPath = \\Africa_HiTech-Out_In_The_Streets-(WAP315DV)-WEB-2011-KOUALA
5: FileCount = 1

3: FolderNumber = 1
6: FileNumber = 1
7: FilePath = \\Africa_HiTech-Out_In_The_Streets-(WAP315DV)-WEB-2011-KOUALA\01-africa_hitech-out_in_the_streets-kouala.mp3
5: FileCount = 1

3: FolderNumber = 2
4: FolderPath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320
5: FileCount = 2

3: FolderNumber = 2
6: FileNumber = 1
7: FilePath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320\01-appleblim_and_october-ny_fizzzzz.mp3
5: FileCount = 2

3: FolderNumber = 2
6: FileNumber = 2
7: FilePath = \\Appleblim_And_October-NY_Fizzzzz-(PLATTER001)-WEB-2011-320\02-appleblim_and_october-fountains_of_paradise.mp3
5: FileCount = 2

I feel so stupid that i cant accomplish this. If i could just use my variables outside the loops my problems would all be solved.. Hope you can help!

Thanks for any response from you coding wizards!

There are restrictions in the Mp3tag Export Scripting Language, I have pointed out.
I assume that it is necessary to create some custom tag-fields, which you fill with the correct values ​​in order to use them in an export. After exporting you can delete the custom tag-fields.

Or write two export scripts, which creates text data files for both cases, with the proper values in order to load the values back into the files into the tag-fields using converter 'Textfile - Tag'.

Proove your concept of numbering with a serial number.
Once you have to insert a new item into the set, you have to renumber the complete set.
This is inefficient.

DD.20110602.0914.CEST

I have pity with you, so I wrote a Mp3tag MTE export script, which generates a VBScript VBS command file, which generates a CSV text file, which can be used as input for the Mp3tag converter 'Textfile- Tag' to set a serial number for each folder and within each folder for each file.

20110602.Export_VBS_SerialNumber.mte (5.6 KB)
Note: After downloading this MTE script, ...
please replace in the very first text line ... within the function $filename ...
in the second parameter ... the word "UTF-8" with the word "ANSI".

DD.20110602.1234.CEST, DD.20150724.1020.CEST

20110602.Export_VBS_SerialNumber.mte (5.6 KB)

I am lost with words on the way you help people with their problems.. This is really fantastic, thank you so much for helping me out on my quest to get my export right and working!

Creating some custom tag fields is no problem as long as i don't overwrite the original source file (MP3). I also thought about the two text files option, but wouldn't know where to begin...

The .vbs option didn't even come to mind......

The mp3tag generation of the vbs works fine, but when i click on the .vbs to execute i get an Windows Script Host error? Am i missing something or doing something wrong here?

QUOTE (necrosis @ Jun 2 2011, 16:23) <{POST_SNAPBACK}>
I am lost with words on the way you help people with their problems.. This is really fantastic, thank you so much for helping me out on my quest to get my export right and working!

Creating some custom tag fields is no problem as long as i don't overwrite the original source file (MP3). I also thought about the two text files option, but wouldn't know where to begin...

The .vbs option didn't even come to mind......

The mp3tag generation of the vbs works fine, but when i click on the .vbs to execute i get an Windows Script Host error? Am i missing something or doing something wrong here?

:slight_smile: Changed UTF-8 to ANSI and then it exports the txt file.

Now on to figuring out the rest :smiley:

Thanks to your help i got everything almost ready for processing :smiley: Without your help i wouldn't have come this far in a million years! Your examples really given me a boost in understanding MP3TAG its possibilities and limitations.

I still have two mayor problem left where i have spend the night on trying to solve (yes again now the fourth day in a row...). Seems like i can't tackle these problems so any help is REALLY appreciated!

First problem i am facing:

Is the extraction/renaming of mp3 files, here a couple of example files:

Cameo-1xtra_Showcase_Live_on_Radio_1_(Jason_Kaye_Guestmix)-CABLE-05-22-2011-uC
3rd_Party-3RD02-noise_factory-1992-sour
Dillinja_-_Cybotron-Retail_CD-2001-BOSS_INT
Refresh-Your_Skills_Once_In_A_While_By_Pressing_Buttons-2011-404
VA-Hardware_XV-15_Years_Of_Renegade_Hardware-(HWAREXVCD1)-3CD-2011-hM
VA-Legendary_Sounds_Volume_1-RIVETCD21-2005-PiCKLE_iNT
VA-MOS_The_Mash_Up_Mix_Bass__Mixed_By_The_Cut_Up_Boys-2CD-2011-BPM
Kromestar-Bonafied_Hustlahz-(DPH003)-Vinyl-2010-BNP
white_label-unknown_artist-bw001-(200x)-sour

Basically remove the last part (which can consist out of character and or number) but is not allways present to should check, remove the year and encapsulation (always written as 4 numbers or three numbers and any character e.g. 200x, sometimes accompanied bij encapsulation e.g. (1999)

Secondly i would really like to copy the ALBUM ID's to a separate tag field %albumsort%. These ID's are currently not in the Tag fields, but only in the directory name :frowning:
This are ID's like (DPH003), 3RD02 or RIVETCD21). These album ID's are always formatted like this e.g. Any word character times * followed bij two or 3 numbers =>DPH003
Sometimes they are encapsulated bij () and sometimes bij spaces or the - signs.
It would be visually nice to give each first character a YUppercase and the ALBUM ID all uppercases.

When done i would be ecstatic if the result will show:

Cameo-1xtra_Showcase_Live_on_Radio_1_(Jason_Kaye_Guestmix)
3rd_Party-3RD02-noise_factory
Dillinja_-_Cybotron-Retail_CD
Refresh-Your_Skills_Once_In_A_While_By_Pressing_Buttons
VA-Hardware_XV-15_Years_Of_Renegade_Hardware-(HWAREXVCD1)-3CD
VA-Legendary_Sounds_Volume_1-RIVETCD21
VA-MOS_The_Mash_Up_Mix_Bass__Mixed_By_The_Cut_Up_Boys-2CD
Kromestar-Bonafied_Hustlahz-(DPH003)
White_Label-Unknown_Artist-BW001

And be presented cleanly in the output like:

Cameo - 1xtra Showcase Live on Radio 1 - (Jason Kaye Guestmix)
3rd Party - Noise_Factory - 3RD02
Dillinja - Cybotron - Retail CD
Refresh - Your Skills Once In A While By Pressing Buttons
VA - Hardware XV - 15 Years Of Renegade Hardware - HWAREXVCD1 - 3CD
VA - Legendary Sounds Volume 1 - RIVETCD21
VA - MOS The Mash Up Mix Bass - Mixed By The Cut Up Boys - 2CD
Kromestar - Bonafied Hustlahz - DPH003
White Label - Unknown Artist - BW001

Second Problem

Second problem im facing is that when i add new songs to my library and run your awesome vbs script again, everything gets renumbered.... Is there a way to only update new and or changed songs? I thought of using filters? but i don't know if that is the best way to approach this? Maybe store the last catergoryid and productid in a text file and go from there?

And that's about it....... Not your everyday problem around here i guess... I feel so stupid that i cant solve these (even after two nights of coding).

Thank you all for any help you can give me in trying to solve my technically challenged questions :slight_smile:

If data is as wildly structured as this, I would always use filters to see whether any wildcard action really hits the files I want to manipulate.
If I have a look at the examples it looks like the following pattern to me:

-_-
So any string you want to chop off the end from has the pattern
underscorehyphen.
A filter with
%filename% MATCHES ".-..-."
should filter all those that still have a hyphen at the end.
Then you could perform a replace with regular expression action to chop off the end until you are left with no other hypen than the starting one.

One problem that you have to solve for yourself is the wish to in some cases keep data at the end

and sometimes not.
Also the change places bit in

requires a lot of clairvoyance by a program/script...

Thanks for your reaction :slight_smile:

I have done some serious diggin on ReEx and written a script to do most of what i need!

\b[\d0-9]?([a-z]{2,}?[\d0-9]{2,}?|[a-z]{2,}?[\d0-9]+[a-z]+|[a-z]{4,}?[\d0-9]+|[a-z]{2,}?[\d0-9]{2,}?|[\d0-9]+[a-z][\d0-9]+|[\d0-9]{5,})\b

9 times out of 10 it filters out the Album ID:

VA-Points_in_Time_007-(GLRPIT007)-CD1-2000-CT_INT
XL_Recordings-XLS24CD-SL2-1991-sour

It picks up GLRPIT007 and also XLS24CD.

I have searched everywhere, but how can use this regex and manage to match these within a directory field and put this in a custom Field? I only see the replace function within mp3tag?

Anybody has knowledge on this?

I have turned to Visual Basic as i believe it is not possible within MP3TAG....

Take a look at the Actions (Alt+5)
Format value with $regexp() function and Replace with regular expression can be used.

Hi Dano,

Thank you for your response. I looked at that, but i cant seem to figure out how to do this. I do not want to replace anything i just want to match the Albumid within the Directory and place this match in a tag field? Could you please help me? I looked all around the forum and couldn't find any topic related to my problem.

Ok this one seems best:

Action type: Guess values
Source format: $regexp(%_directory%,'\b\d?([a-z]{2,}?\d{2,}?|[a-z]{2,}?\d+[a-z]+|[a-z]{4,}?\d+|[a-z]{2,}?\d{2,}?|\d+[a-z]\d+|\d{5,})\b',~$1~,1)
Guessing pattern: %dummy%~%albumsort%~%dummy%

  • I shortened [\d0-9] to \d