Swapping Colons in tags for dashes in filenames?

I LOVE THIS PROGRAM. It's rekindled my enjoyment of music.

Some of my tags use characters that are forbidden in filenames. This file, for example, uses a colon and a slash in two of its tags:

Artist: Star Wars
Title: The Desert / The Robot Auction
Album: Episode IV: A New Hope
Track: 04
Year: 1977

When using the "Tag - Filename" command, I get a filename that looks like this:
Star Wars _ Episode IV A New Hope _ 04 _ 1977 _ The Desert The Robot Auction.mp3

It replaces the colon found in the Album tag and the slashes found in the Title tag with double-spaces.

Is it possible to get the program to substitute a " : " with a " - " and a " / " with a "+" when using the "Tag - Filename" command?

Desired Filename: Star Wars _ Episode IV - A New Hope _ 04 _ 1977 _ The Desert + The Robot Auction.mp3

1 Like

Yes: $replace(%artist% _ %album% _ %track% _ %year% _ %title%,:,-,/,+)

You could enclose the whole expression that you normaly use in Converter>Tag-Filename into the scripting command $replace()
Like
$replace(%artist% _ %album% _ $num(%track%,2) _ %year% _ %title%,:,-,/,+)

Thanks so much! This worked perfectly.

How can I reverse this so the "Filename - Tag" command transposes colons and slashes back the other way?

So, from this:

Star Wars _ Episode IV - A New Hope _ 04 _ 1977 _ The Desert + The Robot Auction.mp3

To this:

Artist: Star Wars
Title: The Desert / The Robot Auction
Album: Episode IV: A New Hope
Track: 04
Year: 1977

If you use Converter Filename-Tag, then you would have to treat the fields afterwards with an action group to replace the characters again.

Or use an action of the type "Guess values" in which you replace the characters before you import the data into the separate fields.

Thank you. I'm trying to do what you've suggested, but I am a novice at coding in general.

I know where to find "Guess Values," but I cannot figure out what the string would look like.

Source Pattern: $replace(%_filename%,-,:,+,/)
Target: %artist% _ %album% _ %track% _ %year% _ %title%

1 problem will be that the "-" is no unique separator but also a "normal" character. So you will probably get more colons than you originally had.

That worked great. Thanks again!

But how will you difference later on a real + from a substitute one when seeing such sign in FILENAME?

Or if you catastrophically loose your TITLEs - how will you properly recreate them form FILENAMEs when they will have multiple occurrences of - sign, each possibly meaning something else?

Hey there. The conclusion I arrived at was to assign substitute characters for each illegal character. Prior to this, I wrote a bunch of rules for how songs are to be titled, so I don't expect too much issue. I'm on the last leg of re-cataloging 12,000 songs and I haven't found anything glaring. Here's what I'm doing:
(in tag) becomes (in filename)
: becomes ~
/ becomes +
? becomes ^

My Tag - Filename code looks like this:
$replace(%albumartist% _ %album% _ $num(%track%,2) _ %year% _ %title%,:,~,/,+,?,^)

Some examples:

Artist: Star Wars
Album: Episode IV: A New Hope
Track: 04
Year: 1977
Song: The Desert / The Robot Auction
Filename: Star Wars _ Episode IV~ A New Hope _ 04 _ 1977 _ The Desert + The Robot Auction.mp3

Artist: AC/DC
Album: Live [Deluxe]
Track: 105 (I use "100s" to note disc number on multi-disc albums)
Year (in this case, of performance rather than publication: 1991
Song: Who Made Who? [Live] (performance date) [performance venue]
Filename: AC+DC _ Live [Deluxe] [Live] _ 105 _ 1991 _ Who Made Who^ [Live] (1991-08-23) [Birmingham N.E.C.].mp3

The only thing I'm at risk of losing is my comment info, which contains precise live performance info (date, location, venue, festival name). I need to find a way to output that.

1 Like

I have pretty much the same approach - but just different replacement signs

I chose mine on the basis that I have not seen them in titles and band names and are accessible from keyboard. But of course I had to adjust and unify all naming scheme so that system would not brake upon encountering some very rare cases; and more than once had to adjust parts of it