Filesize variable

Is there a reason we can’t see and work with the filesize tag or variable?

There is no filesize variable in the current Picard.

But the good news is that it will be available in Picard 3

5 Likes

A Track Metadata plugin should be easily writeable to provide this in a backwards compatible fashion.

I have tried using the View Script Variables plugin but even that can’t read the filesize attribute. I’ve been going through the plugins source code but can’t for the life of me figure out the issue with just that 1 file property. Any other file property is usable in picard as a variable and/or a tag except filesize.

This would be a great tool to help identify duplicate files.

The View Script Variables plugin (which I wrote) does exactly what it says on the can - it shows you metadata variables that can be used in scripts - both hidden and shown in the metadata pane. filesize is not (currently) one of the values stored as a script variable so it is not shown.

However a plugin should be possible to easily be written to create such a variable (but I don’t have the time to do it myself).

The other problem with filesize is that it doesn’t necessarily stay constant (when you save a file, the change in metadata can result in a change of filesize) and duplicate tracks don’t have to have the same filesize (so acoustid is probably a better metric to determine duplicate music files).

Especially if you embed a large cover image…

Thanks for the information @Sophist. I have been trying to write a separate plugin to integrate file size but I don’t have any experience with Python or the Picard API. I have only worked with .net languages. I am slowly working my way through it but I may just wait for 3.0. I hope you don’t mind me using your plugin to learn the ropes. To be honest, picking apart your source code and occasionally referring back to that has taught me more than any of the plugin guides for Picard. Again, thanks for that and the quick responses!

My issue currently is that a band (311) I follow releases free live recordings quite regularly through their website/membership. These will get identified in Picard as some of their recordings, especially their live albums. On top of that I have duplicates of all my songs due to OneDrive. I have been using file size to determine which set of duplicates are the free releases vs the album releases after saving them both with the same tag data from Picard. That way I can be assured I don’t delete one of these recordings due to thinking its a duplicate.

There are two (or three) ways to deliver this:

  1. A PR to Picard itself adding a few lines to the code that e.g. populates other fixed data like the bitrate to add the filesize; if this code has already been added to the v3 branch, you could probably just copy it across.

  2. A plugin - a bit trickier - you would have to decide what hook(s) to use - since this is file related, you probably need to hook into the file related extension points. I can’t remember whether the file information can reside as part of the file or only as part of a track but my guess is that you would need to hook into 2-4 of the file_post_* extension points defined on the Appendix A: Plugins API — MusicBrainz Picard v2.13.3 documentation page. But once you determine where the information needs to be stored and how it makes it to the track metadata used by scripts, then it should only need a few lines of simple python code to achieve.