Problem with %tags% in a filenaming script

Hi,

I’m having a problem with tags in a file naming script. Pretty much any dereference of a tag gets ‘/’ replaced with ‘_’. Is there a way of turning this off?

For example using this track: Recording “LA Drone / Immigrant Song” by Led Zeppelin - MusicBrainz

We have %title% and %catalognumber% both with a ‘/’ in them. If I want to replace them with U+2215 ‘∕’ using $replace(%title%,/,∕) it doesn’t work as %title% comes back pre-filtered to ‘_’.

A more complete example would be

$if(%catalognumber%, [$replace($replace($getmulti(%catalognumber%,0),_,∕),\\,∖)])

Is there a mode switch I can flip to bypass this behavior?

Even better would be a global filter I could set for ALL tag dereferencing :grinning:
It would look something like this

$replace($replace($replace($replace($replace($replace($replace($replace($replace(
%anytag%
,:,∶),?,ʔ),*,⁕),<,◀),>,▶),",“),|,∣),/,∕),\\,∖)

What characters are forbidden in Windows and Linux directory names?

there is a plugin called “Replace Forbidden Symbols”, you can find it under Options → Options… → Plugins. the description:

Replaces Windows forbidden symbols: :, /, *, ?, ", ., | etc. with a similar UNICODE version. Currently replaces characters on “album”, “artist”, “title”, “albumartist”, “releasetype”, “label” tags. Also add $replace_forbidden() function for Tagger. Example: $set(composer,$script_forbidden(%composer%))

I haven’t personally used it myself, so I don’t know how exactly it works, tho~

4 Likes

Do the replacements already on load in a tagger script (Options > Scripting). If you don’t want the replacement being done to your tags use a different variable name. E.g.

$set(_title,$replace(%title%,/,\u2215))

Then in your naming script use %_title%

2 Likes

Thank you. It seems to work first off without any work on my part at all. The ‘global filter’ I requested :wink:

This doesn’t work, so I’ll follow your advice on a tagger script for doing replacements

$if(%catalognumber%, [$getmulti($replace_forbidden(%catalognumber%),0)])

Ok, got it. Thank you both for the help. It seems to be a global rule in a filenaming script that dereferencing any tag applies the rule of replacing a forward slash with an underscore. But adding more tags not covered by the ‘replace forbidden symbols’ plugin does the trick

$noop(
Extend 'Replace Forbidden Symbols' plugin to incude everything I would need
)
$set(catalognumber,$replace_forbidden(%catalognumber%))
$set(_releasegroup,$replace_forbidden(%_releasegroup%))
$set(_releasecomment,$replace_forbidden(%_releasecomment%))
$set(albumartistsort,$replace_forbidden(%albumartistsort%))
$set(artistsort,$replace_forbidden(%artistsort%))

Oh, I’m kinda slow, but I just realized plugins are non-compiled script in text form. Now I’m having fun

davygrvy@puukukui:~/Documents$ diff replace_forbidden_symbols.py.orig replace_forbidden_symbols.py
39c39
<     "/": "⁄",
---
>     "/": "∕",
41c41
<     "?": "?",
---
>     "?": "ʔ",
46,47c46,47
<     '<': '‹',
<     '>': '›'
---
>     '<': '◀',
>     '>': '▶'
56a57,61
>     "catalognumber",
>     "_releasegroup",
>     "_releasecomment",
>     "albumartistsort",
>     "artistsort",

All variable’s get their slashes replaced before they get passed to the file naming script. That’s because slashes will create directories, and you don’t want your AC/DC albums and up in a folder hierarchy of AC and DC.

1 Like

AC_DC looks silly as a directory name. AC∕DC (\u2215) looks much better

1 Like

It probably depends on your system and font settings, but it actually looks really horrible here :sweat_smile:

grafik

But there is a long standing feature request to make the replacement character for this and various other cases configurable.

2 Likes

\u2215 is better than \u2044 as that behaves like a combining character and super/sub scripts numbers for showing fractions. That feature request would have to get forwarded to the unicode governing body

\u27cb? AC⟋DC
\u29f8? AC⧸DC