Tagger-Script: current time?

Tags: #<Tag:0x00007f050d39d280> #<Tag:0x00007f050d39ce70>


Hello, i want to add a custom tag to my audiofiles with the current timestamp when i am processing them via picard and adding them to my archive. Is there some way to do this with the tagger script?

thank you :3


I find it interesting that nobody requested this before :slight_smile: It is not possible with Picard out if the box, but a simple plugin could add a tagger script function for that. I can’t properly type one right now, maybe somebody else here wants to write it? :joy:

If not I’ll try to remember to post the plugin here tomorrow.


thanks for the hint with the plugin, i thought i try myself and i don’t know what i did exactly but it seems to work.


# -*- coding: utf-8 -*-
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2.
# See http://www.wtfpl.net/ for more details.
PLUGIN_NAME = 'timestamp'
PLUGIN_AUTHOR = 'ehrgeiz'
PLUGIN_LICENSE_URL = 'http://www.wtfpl.net/'
PLUGIN_DESCRIPTION = '''Adds a timestamp function to tagger-script'''
from picard.script import register_script_function
def timestamp(parser):
	import datetime
	now = datetime.datetime.now()
	return now.strftime("%Y-%m-%d %H:%M")

and my taggerscript is then


i don’t know why i have to write something in parenthesis in the “def timestamp()” but i guess this works now. maybe i should set check_argcount:false?


Great, that’s exactly what I had in mind. One thing to note is, that if you place this function in Options > Advanced > Scripting it will be executed when the data gets loaded from the server. If you place the function in the file naming script (e.g. to have the timestamp as part of the file name) then it will get executed when you hit save.

The first argument to any script function is a parser object, which gives you access to metadata and some internal stuff. Not needed here, but for correctness just call it parser:wink:


Awesome! Thanks for this, I can finally do this: https://www.youtube.com/watch?v=AQvOnDlql5g

@ehrgeiz did you happen to actually test if your $if2 actually works for you? i.e. Is it preventing your old value from being overwritten? For me, it always overwrites the field, even if it already contains a value.

As far as I can tell, only the fields listed at https://picard.musicbrainz.org/docs/tags/ can be accessed using %fieldname% - so a custom field name always returns null and therefore $if2 will always return the 2nd argument.

Or have you done something to make %Dateadded% work for you?


You are of course right, I just found out myself that the timestamp is overwritten :frowning:

maybe someone can tell me if it is possible to read out the tags from the file? I browsed to some plugins to find a reference I can lean on, but I haven’t found a plugin that reads the tags from the files itself.


Can’t help with a plugin sorry.

But I’m not sure why Picard itself doesn’t just parse all tags by default, kind of like foobar2000 does. Can’t see why that’d be a problem, but it hasn’t been implemented.