Adding profile to custom tag for each track

I have different profiles setup in Picard for music from different sources. I’d like to add a custom tag to each of of my tracks (mostly FLAC & MP3 files) where the tag is named ‘source’ and the value is the name of the Picard profile that was active when the track was saved. If it makes a difference, not all sources will have musicbrainz data (if I don’t know the label/catnum and can’t link to the proper musicbrainz ID I prefer to not include any musicbrainz tags). Can I accomplish this through a taggerscript, or do I need to create a plugin, or ?

1 Like

You can $set whatever field you like to see in your tags, for example
$set(source,"ProfileName")

But I don’t think that there is a script-variable containing the current profile name.

4 Likes

First thing to remember is that there can be more than one profile active at a time, which could complicate things. Also, there is currently no scripting variable that contains the currently active profile names.

Having said that, one way you could accomplish what you’re trying to do is to set each profile to manage the tagging scripts, and then add a script to each profile that sets the tag to the profile name. Something like:

$set(source,Picard profile name)
4 Likes

Bingo. That’ll work, thanks!

2 Likes

As an alternate option (I find I often forget to switch profiles), I’m wondering if I can have the source tag determined by the name of a folder the music is imported from. If each subfolder within Z:\ is a music source (eg. Z:\YouTube, Z:\Bandcamp, Z:\Amazon) is it possible to parse the path to get the folder name and use it? I think something like $set(source,$if2(%source%,$substr(%_filepath%,3,$find($substr(%_filepath%,3),\)))) would find that folder name, but I haven’t been able to tell if _filepath is an actual variable that is available or not (no tag is generated from this tagger script). Also, is there a ‘console’ or other way to tell how Picard is interpreting our formulas or is it always just blindly try something to see if it works?

The available File Variables are listed here:

Maybe you can try it with _dirname?

1 Like

You’re right. I saw that page, and dismissed _dirname because their verbage the directory containing the file made me think it was just reporting the parent folder. I just tried dumping _dirname to the variable and it in fact includes the entire folder path up to and including the parent folder. Strangely enough, I have Z:\ mapped to a share on my NAS, and Picard accesses the files through that mapping, but the path that is returned is the UNC path, not the mapped path. Anyway, thanks for nudging me back to that page so I could do more testing. Hopefully I can make something work with this now that I have a path to deal with!

I did get it working, here’s what worked in case anyone is trying to do something similar:

$set(source,$if2(%source%,$substr(%_dirname%,X,$add(X,$find($substr(%_dirname%,X),\)))))

Replace ‘X’ with the number of characters in the UNC path before the name of the folder that you want to use as the tag. The formula uses substrto just grab the folder name I wanted, with the first substr number being the number of characters to skip over to get to the beginning, and then searching the remaining characters for a ‘\’ to determine the length of the folder name, and then adding the beginning length and the folder length to get the second substr number. If a source tag already exists, it leaves it alone, if not, it creates it with the derived value.

As an example, if I have a folder at \\TheMachine\Media\Music\ToProcess where I put my music to be processed, and have subfolders called Amazon, Bandcamp, Deezer, etc then I would set X in the script to 34 which is the number of characters leading up to the source folders. The formula would then return Amazon, Bandcamp or Deezer depending on the folder the tracks were in and would set a tag called source containing that as the value.

1 Like

It sounds to me like you should try out the Shelves plugin. :blush:

I’m having a look at it. Might be useful, will have to play with it a bit.

One thing I think I’m noticing though is that you only have 1 ‘shelf’ tag, which presumably shows the current shelf. If I defined my ‘sources’ as shelves, I’d be looking to keep track of my original shelf, so I could tell where the album came from (eg. was this one of my CDs or my wifes? Did this come from Amazon or YouTube?).

Presumably with the way your plugin works, albums from the “Joe’s CDs” shelf would get moved to the “Standard” shelf, and the tag would change to “Standard” so I’d loose insight on it’s source. Am I correct in this assumption?

Yes, that conclusion is (unfortunately) correct. To do that, you would have to write down a history. I’m sorry, I should have read more carefully what you were planning to do.