Tilde use in source code in variables?

In scripts, we have %variable% and %_variable%.

The former are tags from the files, the latter are variables created in scripting.

In the source code, however… there are also references to'~variable' and 'variable'. Some you see the same word either way. How do we know that the tilde is required, or if it’s not required, optional, etc?

Like I had originally put ['length'] in there, and didn’t see anything on the script sample, so I also put ['~length'] in with a different value so I could see which one was coming through.

Is the tilde usage with regards to Picard documented somewhere? I know it gives the complement of the value, but I’m not clear on why the complement matters with length then, or a few of the others with it.

    file.metadata['media'] = '12 Inch Maxi'
    file.metadata['label'] = 'Apple Records'
    file.metadata['releasetype'] = ['album', 'soundtrack']
    file.metadata['~primaryreleasetype'] = ['album']
    file.metadata['~secondaryreleasetype'] = ['soundtrack']
    file.metadata['releasestatus'] = 'Official'
    file.metadata['releasecountry'] = 'US'
    file.metadata['~extension'] = 'mp3'

Variables starting with a tilde are not written to tags but are just there to hold a value. They are sometimes called hidden variables.

Originally these contained the technical details about a file, such as bitrate. But later additional variables where added for other data we wanted to make available to scripting without writing it to the files by default.

In scripts those variables are accessed using an underscore. I’m not sure what the original reason for this difference was, but that’s how it works.

2 Likes