Repository for neat file name string patterns and tagger script snippets

HI Tdiaz, You’re the author of the magic script right?
First what a brilliant script, thank you.
Theres just one issue for me and i’ve been scratching my head for an hour trying to make it work. When the item is a compilation, or soundtrack etc I dont want the alphabetical sorted subdirectories. e.g Various\Album_name (not Various\A\Album_name)
Is that possible?

Hi

I’m looking to try and use the ‘magic script’ to start the process of organising my music from multiple sources, HDD’s, USB’s etc. I’m planning to dump everything into a NAS, and i’ve been through some of the older posts for as much info as I can find regarding this.
Just wanted to confirm its still only possible to use this script if you build from the source code as per “Plugin Capabilities & a 'fix' (Q&D hack) for dealing with duplicate files in the album directory”.
Do I need to use a specific build version or is the current build ok?
Also, how difficult a process is this for a relatively newbie with Picard?

Thanks in advance

1 Like

This is a great question…I would like to know too. For me, I consider a song a duplicate as Album + MB ID (song id?) + Acoustic Fingerprint. I have songs that are on multiple albums that are the same but I do not consider them duplicates. Can Picard do this?

Whatever happened to the list of pre-made scripts that was here? This redirects to the current documentation (which is as it should be), but I couldn’t find the actual scripts there.

Update, I think I found it here: Scripts — MusicBrainz Picard v2.10 documentation
I was looking here: Scripting — MusicBrainz Picard v2.10 documentation

Hello, my last and all day script:

$if2(%artists_album_primary_std%,%_artists_album_primary_cred%,%albumartist%,%artist%,NO-ARTIST)
/
$upper([$if2($getmulti(%releasetype%,2),$getmulti(%releasetype%,1),$getmulti(%releasetype%,0),NO-RELEASETYPE)])
/
[$left($if2(%originaldate%,%originalyear%,%date%,0000),4)] $if2($if(%albumartist%,%album%,),NO-ALBUM)
/
$if($gt(%totaldiscs%,1),Disc%discnumber%/,)$if($and(%albumartist%,%tracknumber%),$num(%tracknumber%,2) - ,)$if($if2(%_artists_track_all_cred%,%_artists_track_primary_std%,%_albumartists%,%artist%,),$if2(%_artists_track_all_cred%,%_artists_track_primary_std%,%_albumartists%,%artist%,) - ,)%title%

Easy and quickly rename like this:
/Music/Arstist/[Releasetype]/[Year] Album Name/Disc1/track number - Singers - title.ext

Ex:

/Musique/Bruno Mars/[ALBUM]/[2010] Doo-Wops & Hooligans/01 - Bruno Mars - Grenade.mp3
/Musique/Depeche Mode/[COMPILATION]/[2006] The Complete Depeche Mode/Disc16/21 - Depeche Mode - Everything Counts (live).mp3
/Musique/Eminem/[MIXTAPE_STREET]/[2010] A Beautiful Mind/02 - Eminem feat. Nicki Minaj - Roman’s Revenge.mp3

2 Likes

(post deleted by author)

1 Like

@rdswift @Billy_Yank and at everyone LOL
OK…here goes…it look like rdswift and Billy_Yank’s scripts look like what I’m looking for my music. I have three folders: CD (all my music that I actually have CD’s converted), HD (all my digital hi-res music), and Music (all my digital MP3’s and iTunes non hi-res music). I want the script to keep the music in these three folders. I like how the scripts separates music in A,B,C folders for quicker search of artists by last name. I like the padded track and disc numbers by how many tracks per disc. For example, if the disc has over 100 tracks I would like it to show 001-100 (disc 1 track 100). I prefer my various artists albums to be under folder V and folder Various Artists. All this is the minimum I’m looking for…having dates included in the album folder is fine…I don’t mind the extra info. It looks like over the years changes have been made…so could you repost with your latest script(s)? The only thing I’m mainly concerned about is keeping my music in their main 3 folders (CD, HD, and Music).

On another note, I am curious about the language used for Picard. In high school and college, I have taken complete basic, basic, C, C++, Java, and an HTML course that covered HTML, DHTML, CSS, Javascript, Javabeans, etc. With all those classes, I never have come across all these /'s…LOL…is that something new now with the newer languages? I don’t like it…doesn’t look good and must be a pain in you know where for debugging.

Also, what program do you use now for writing these scripts? Still Notepad +?

My latest script is always available in my repo on GitHub. As you can see, it hasn’t been updated in quite a while.

There is a snippet in the repo showing how to automatically pad the disc and track numbers to match the number of discs or tracks available.

Picard itself is written in Python. The scripting language was initially based on that used in Foobar2000’s titleformat. For more information, have a look at the Scripting section of the Picard User Guide. The slashes in the file naming script are used to create subdirectories.

I actually do most of my script editing right in Picard so that syntax error checking and such is done in real-time. The added benefit to using Picard for file naming script development is that you can see example output immediately as well. If I need to use an external editor for major script work, I generally use VS Code which is what I use for most of my program code development.

4 Likes

The slashes are not part of the language. The filenaming scripts are building a file path, and slashes are directory separators. The result might be something like “Music/J/Michael Jackson/Thriller/04 Thriller.mp3”, the slashes indicating the directories. Oh, and slashes have been used for this purpose since somewhere in the 1970s, so they are not exactly a new thing :smiley:

1 Like

Would you mind posting your latest script(s)? Looks interesting and I might want to use it with my music too :slight_smile:

1 Like

@rdswift I have been trying some of the scripts in this thread and found yours to be the closest to what I would like, but I can’t seem to figure out how to change the artist folders to Firstname/The/A/An etc.. instead of Lastname, first. I have sorted my music like this for over 20 years and am not emotionally ready to deal with that jarring change. :wink:

Is there a setting I’m missing?

On another note, I was curious if it is possible to script translations of embedded ratings tags to a standard tag like POPM? Over the years I’ve embedded tags like fmps, banshee, amarok, quodlibet, and I’d like to standardize them if I could.

Thanks!

@akovia, if I understand your request correctly, I think it can be achieved by replaing the current line 417

$set(_nFilePath,%_nInitial%/%_nFAAPS%/%_nYear% %_nANT%/)

with

$set(_nFilePath,%_nInitial%/$swapprefix(%_nFAA%,A,An,The)/%_nYear% %_nANT%/)

Note that I haven’t tested this, so you may need to experiment a little.

Fantastic!
I guess I’m an outlier, but an option at the top might make a nice addition. I notice that the default included scripts appear to format in the same way for the names at least. Not sure about A/An/The though.

I really appreciate it!

Any thoughts on translating ratings?

That should be handled by the $swapprefix() command.

No, because I wasn’t sure I understand what you’re trying to do. Can you provide more of an explanation?

No, because I wasn’t sure I understand what you’re trying to do. Can you provide more of an explanation?

Yes, I apologize for not explaining better.

I have used different music players over the years and when possible I had them embed my ratings into the tags so I could keep the reference in hopes that another player might be able to read them in the future. (Never seems to be the case of course)

Out of all the ratings that have been used over the years, it seems to me that POPM is the most “Popular”. (pun intended) I think mostly because of the email reference that allows multiple users to share the same library with different ratings. Quodlibet adopted this strategy as well, but the player itself is not well known.

So I’m trying to script a way to identify the various tags I’ve used in the past, and translate them to the POPM format. Mostly reading from a 0-100 scale to the 1-255 scale of POPM. Adding the email and play count portion of POPM as well.

POPM = email@somehwere.com|1-255|0

I wrote about this five years ago here and it looked like it might get some love, but just kinda died.

Might not be a good fit here either, but never know until you ask.

Thanks again!

Edit: I should state that right now I’m only interested in mp3 tags. I realize everything gets more complicated the more formats you add.

Thanks for the extra explanation. I’m not really a guru regarding mapping of tags and how they are stored in the files (far from it actually), so I don’t think I can help you on this one. Sorry.

No worries, thanks for having a look!

If anyone out there is missing seeing the full Sample Rate in kHz, the code below will will add one decimal place where appropriate like 44.1kHz or 88.2kHz, but where not needed will provide output like 96kHz or 192kHz.

$div(%_sample_rate%,1000)$if($gt($mod(%_sample_rate%,1000),0),.$div($mod(%_sample_rate%,1000),100),)kHz
3 Likes

I have pulled many ideas from your script and appreciate all the work you put into it. One thing you may wish to add to the Tag Formatting section that I did not see is the following replacement for the appropriate tags:

$noop(★ / ➡ ╱ [Box Drawing... U+2571])
$set(_titleForFilename,$replace(%_titleForFilename%,/,╱))
$set(_albumForFilename,$replace(%_albumForFilename%,/,╱))
$set(_discsubtitleForFilename,$replace(%_discsubtitleForFilename%,/,╱))

In my script, I append the Release Comments to the Album and have recently come across several containing /s that get replace with _ in the file name structure. Options I looked at were:

'⁄' - FRACTION SLASH (U+2044) {Does not look nice with variable width fonts}
'∕' - DIVISION SLASH (U+2215) {Does not look nice with variable width fonts}
'╱' - BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT (U+2571)

Not sure if one is better than the other across different systems.

I’ve added a few replacements of illegal characters too, but for @rdswift naming script

    $set(%_loop_value%,$rreplace($get(%_loop_value%),[*],-))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),:, \u2236))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[?],!))
    $set(%_loop_value%,$rreplace($get(%_loop_value%),[`´‘’ʻ""“”],'))

However i can’t seem to make a slash replacement work. Don’t know what i’m doing wrong.