Script - Add Custom Tag With Current Date

I am trying to write a script that will add a custom tag for FLAC files called, “Date Acquired” and populate it with today’s date. So far what I have isn’t working.

$set(%Date_Acquired%, $datetime())

Any ideas?

Try removing the percent signs around your destination tag name, as:


Also, if you want this stored as a tag in the files, it needs to be in a tagging script rather than your naming script.


Thanks for the quick reply. How exactly would I do that?

I assume that you mean how do you enter the command in a tagging script. The tagging scripts are found in the Scripting section of the Configuration options. There is some additional information in the Scripts section of the Extending Picard chapter in the Picard User Guide.

I was hoping for help with the syntax since I’m not a scripter.

So far my Tagger Script looks like this

if (Date_Acquired="") $set(Date_Acquired,%Date_Acquired%))

The second line is not a valid script syntax. Your script should look something like:


The only problem is that existing tags from a file are not (yet) available for use in a tagging script, so %Date_Acquired% will always be blank when the script is run, thus it will always be set to the output of $datetime(). There is a request to make the file tags available to the tagging scripts.


OK so what I want to do I have to do manually for now. I’m surprised there’s not a built-in variable for this. File Modified dates are never reliable, so having a tag with this information would be helpful.

If you set a tagger script to:


and enable it, when you tag your files it will automatically include a tag called Date_Acquired with the current date/time stamp. No manual intervention required. If you want just the date, change the script to:


The only thing is that if you re-tag your files at a later date, the tag value will be changed to the new date. You may be able to avoid this happening by adding Date_Acquired to the Preserve these tags from being cleared or overwritten with MusicBrainz data list in the Before Tagging section of the Tag Options settings. (I haven’t tested it.)


Another option would be to put the $set command in a separate script that’s not enabled and run it manually when you first tag your files.

Then it should be preserved when you update your files again.


You must have read my mind. I was trying to get rid of the time stamp and didn’t realize I need the escape slashes.

This worked great. Thanks!