Can I set the track number tag based on the filename?

Tags: #<Tag:0x00007fe316b2e070> #<Tag:0x00007fe316b2db20> #<Tag:0x00007fe316b2d468>

When tagging with Picard, is it possible to set the track number tag of a file based on the filename?

I have files named “01 foo.mp3”, “02 bar.mp3”, … and want to tag the files with track numbers based on the first two characters of the filenames (01, 02, …)

Thanks

If I understand you correctly, you want to save the first two characters to a tag in the file, such as $set(my_special_tag,$left(%_filename%,2))? If so, I can’t think of a way to do it because you can’t set a tag value in the file naming script, and the %_filename% variable isn’t available in the tagging scripts.

If I misunderstood, and you want the new file name to have the same two-character track number as the original file name, that should be easy enough. You can get the first two characters by using $left(%_filename%,2) in your naming script, and then use that value.

See the _filename variable in the Basic Variables section of the Picard Docs for more information.

I can think of a way to accomplish this by using a different application than Picard (sorry if that’s not helpful to you): In Mp3tag, you can use the “Convert” > “Filename - Tag” function to set the track number from the filename. Based on your examples “01 foo.mp3” and “02 bar.mp3”, you can use the format string

%track% %dummy%

if you only care about the track number, or

%track% %title%

if you also want to set the track title from the filename. The %dummy% placeholder is used to ignore certain parts of the filename.

1 Like

Use Tools > Tags from filenames

2 Likes

Thanks all.

@rdswift: I’m tagging stuff that’s not in MB which is why I’m trying to get tag information from the filename, although Picard may not be best software for this, as suggested by @wlhlm.

Having said that, I was completely unaware of the “Tags form filenames” feature as suggested by @outsidecontext, which should do the trick.

1 Like