Replacing "smart quotes" with apostrophe in filenames

329 views
Skip to first unread message

Mark

unread,
Oct 14, 2015, 12:54:40 PM10/14/15
to beets
Hi everyone,

When beets changes the file name for a song that has "smart quotes" (e.g. left single quotation mark ‘ and right single quotation mark ’), it will use them.

However, I would prefer to have beets use the plain old apostrophe (') instead. I'm looking into using the replace setting, but I can't quite get things to work. Here's what I currently have:

replace:
    '[\\/]': " - "
    '^\.': " - "
    '[\x00-\x1f]': " - "
    '[\x91\x92]': "'"
    '[<>:"\?\*\|]': " - "
    '\.$': " - "
    '\s+$': ""
    '^\s+': ""


Unfortunately, this still doesn't seem to work when I tried to re-import a song which had a smart quote in it, as the resulting file still had the smart quote in it.

Note that I only want this replacement for "smart quotes"; I still want to allow other accented characters (like é) and foreign characters (like あ) through, so I'm not sure if the asciify option is suitable for this case.

Adrian Sampson

unread,
Oct 14, 2015, 1:12:30 PM10/14/15
to beets...@googlegroups.com
This looks about right -- I don't see anything immediately wrong.
Anyone else have something like this working with `replace` instead of
`asciify`?
> --
> You received this message because you are subscribed to the Google Groups
> "beets" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beets-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Oct 15, 2015, 11:18:29 PM10/15/15
to beets
Just wondering... if you tried using replace like this in your own config file, does it work?

Daniele Giglio

unread,
Mar 3, 2017, 6:14:59 AM3/3/17
to beets
Excuse me, can you please explain me where these hex values come from?

    '[\x91\x92]': "'"

According to ASCII table '`' corresponds to x60, and '´' to xB4.
Bye.

Adrian Sampson

unread,
Mar 3, 2017, 10:59:42 AM3/3/17
to beets...@googlegroups.com
Those are Unicode codepoints. For example:

Daniele Giglio

unread,
Mar 3, 2017, 11:45:36 AM3/3/17
to beets


Il giorno venerdì 3 marzo 2017 16:59:42 UTC+1, Adrian Sampson ha scritto:
Those are Unicode codepoints. For example:
 
Sorry if I insist, but it makes non sense to me:

'DEVICE CONTROL STRING' (U+0090)

'PRIVATE USE ONE' (U+0091)

Aren't we talking about quotes ?



Adrian Sampson

unread,
Mar 3, 2017, 12:11:44 PM3/3/17
to beets...@googlegroups.com
Hmm, you’re right—those are not what I thought they were. It looks like those might be the codepoints for single quotes in Latin-1, but that seems like it won’t work in beets…

Daniele Giglio

unread,
Mar 3, 2017, 12:19:31 PM3/3/17
to beets
Il giorno venerdì 3 marzo 2017 18:11:44 UTC+1, Adrian Sampson ha scritto:
Hmm, you’re right—those are not what I thought they were. It looks like those might be the codepoints for single quotes in Latin-1, but that seems like it won’t work in beets… 

Adrian Sampson

unread,
Mar 3, 2017, 12:21:08 PM3/3/17
to beets...@googlegroups.com
Yeah, if you want to match the accent characters—but if you want to match the “curly” quotes, these are they:


Daniele Giglio

unread,
Mar 3, 2017, 12:25:00 PM3/3/17
to beets
Il giorno venerdì 3 marzo 2017 18:21:08 UTC+1, Adrian Sampson ha scritto:
Yeah, if you want to match the accent characters—but if you want to match the “curly” quotes, these are they:

Thanks a lot, dealing with fonts it's always a headache source.
Reply all
Reply to author
Forward
0 new messages