How to Run a Script?

scripting
tagging
filenaming
Tags: #<Tag:0x00007f23c56de8a0> #<Tag:0x00007f23c56de5d0> #<Tag:0x00007f23c56de378>

#1

So, I’ve recently installed Picard and have begun organizing my music. I put everything in clusters, and then moved them over to the right-hand panel where you get the little colored-disc output.

What I’m trying to do now is run a tagging/file renaming script found here. I copy-and-pasted this script into a new entry in Picard’s scripting options. I then went ahead and tried to “Save” a disc-output entry, but the script did not seem to execute. What am I doing wrong here? If possible, dumb it down as I’m not that intelligent honestly.

As for specs, I’m running Picard version 1.4.2 on Windows 10 Version 1703.

Thank you.


Rename album name if the name does not contain "volume"
#2

The primary difference between a taggerscript and a naming script is when they’re run. Namely, anything you put in on the “Scripting” page will only run when the file is loaded or processed, while anything on the “File Naming” page only comes into play when you save. Now that you have the script in your preferences, it will run automatically for any files you open in the future, but in order to update anything that’s already in Picard when you add/change a taggerscript, you have to select the files, right click, and refresh. When doing so, though, you will lose any changes you made manually, so if you’ve done anything big, it’s best to save the files with the old set of scripts before refreshing.


#3

This worked brilliantly. Appreciate you outlining the differences in deployment between the two types of scripts.

I may have to peruse the script further to really get a handle on it and make it do exactly what I want and follow MusicBrainz suggested guidelines, but this is a great starting point.

Thank you!


#4

Glad to help! And, yeah, I’ve heard good things about the Magic Script there, but (with a programming background) I almost find it easier to just write everything myself than to try to figure out what it’s doing. Just to be sure if you haven’t already done so, that’s supposed to go into the “File Naming” page rather than the “Scripting”, so you’re going to need to move it over; the second difference between the two types of script is that taggerscripts ignore any text outside a function or that gets emitted after every function is run, while naming scripts rely on that to determine how to rename the files.

And so you know, you can do whatever you want with your files in Picard. There are three ways your file tags/names affect the database: rating releases or recordings, submitting things via AcousticBrainz, and using the “Submit cluster as release”/Submit file as standalone recording" plugins (I may have gotten their names wrong). The only effect the first has is coloring in some of the stars on the website, the second is designed to handle non-standard tags, and the third will give you the opportunity to fix anything before it’s added. ListenBrainz also receives data, but it’s still a bit difficult to get anything into it without going through Last.fm. Beyond those, nothing is sent back to the database. I personally replace the artist fields somewhat commonly because I disagree that remixes should be listed under the original artist, and then name my files by making everything lowercase, stripping out some of the punctuation, and then replacing the rest as well as the spaces with a combination of underscores and hyphens. Nobody else would want their files looking like that, but because I do, I’m free to mess with them however I think is warranted and it will only ever affect my local copies.


#5

Yeah I have a very loose familiarity with the FB2k system, to say nothing about programming at large; much less a background in it.

The tool (and your tips on what to put where) seems to be working… okay for me. There’s one or two things I’d likely change about how it renames files (i.e. folder & file naming detail conventions, placing everything into an “unknown” folder after saving) but seeing as how I’m mostly interested in long-term storage for reading by a media tool of some kind, the tagging takes precedence.

Thanks again!


#6

Does Picard support direct AcousticBrainz submission now? Or do you mean AcoustID?


#7

I’ll admit I wasn’t particularly clear there, but I was listing everything that is affected by the file tags, not just what goes through Picard. The AcousticBrainz GUI is still to the best of my knowledge the only way to submit things there, but it is affected by my replacing of the artist tags, say. I deliberately left out AcoustID because the audio data it looks at really shouldn’t be touched by any reasonable editing process (though I have heard some things about old ReplayGain implementations…) Thanks for checking, though!


#8

There’s also a CLI for submission, and @Mineo made an additional CLI tool, and beets also has an AcousticBrainz Submit Plugin which submits data to AcousticBrainz.

Well, yes and no. The AcoustID-MB Recording ID association depends on the Recording MBID written to the file tags, so AcoustID submission is not only audio data based. If you link your files to the wrong Recordings and submit AcoustID data based on that, you’ll be submitting wrong data.


#9

Great answer but I’m still having a challenge getting my script to run, assuming it’s correct. Nothing changes when I restart and open my files and I do not see a Refesh option when I right click. There is a Refresh menu item under Tools but it is greyed out.

Any ideas on how to debug this further?

Picard v1.4.2 on Windows

Script is:

$set(title,RBTD Disc %discnumber% $num(%tracknumber%,2))


#10

Refresh only works when selecting the album, rather than any track inside it, and all taggerscripts (not sure about naming scripts) only affect things in the right-hand pane. If neither of those is the issue, then I’m not entirely sure what would be going on. Maybe someone else here has another idea?


#11

Thanks, again that’s useful info - esp about the tagger scripts only running on items in the right-hand pane: I only have items on the left :slight_smile:


#12

You don’t really use Picard until you have items on the right (that is metadata from MusicBrainz and your local files attached to it)