Filtering Quotes

I am planning on re-writing the macro that generates this code to use dumb quotes, but in the meantime, I was trying to convert smart quotes to dumb quotes with the filter action but it doesn't seem to work, what am I doing wrong here?

quote test.kmmacros (3.4 KB)

Interesting. It's only processing the first line.

Apparently that's how the built-in filters work, although the documentation doesn't quite say that.

If your need is immediate, use Text Toolbox II, which has a robust Straighten Quotes option.

First line already has dumb quotes -- there's no filtering at all.

I think it's because smart-quote processing is done in pairs, opening and closing quotes being matched, both dumb and smart. If you change your first two lines to

#!/bin/bash
mv -v "/Volumes/offsite_backup/Backups/Active Projects/030122_WHITE_CASTLE_CHICKEN_CHEESE" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"“Test”

...you'll see that line is processed correctly because there's an even number of dumb quotes then correctly-paired opening and closing smarts. Try adding an extra dumb quote at the beginning, or changing the last smart-close to a smart-open, and you'll see what I mean.

You'll probably need to "Search and Replace" rather than "Filter" -- you can copy'n'paste the smarts into the dialog, or use the hex codes (which are \0x201C and \0x201D, respectively).

3 Likes

Good catch. I had to significantly enlarge the output to see which way the quotes curled. But I didn't enlarge the input, assuming they were curly.

Text Toolbox doesn't process the quotes in pairs to straighten them. Here's the output:

#!/bin/bash
mv -v "/Volumes/offsite_backup/Backups/Active Projects/030122_WHITE_CASTLE_CHICKEN_CHEESE" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/040722_BENJAMIN_MOORE" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/HC-00023_SUBWAY_BTS" "/Volumes/offsite_backup/Backups/Inactive Projects/11_NOV_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/HC-00028_INSTAGRAM" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/HC-00055_KROGER_ECOMM_MOMS" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/HC-00058_GOOGLE" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
 mv -v "/Volumes/offsite_backup/Backups/Active Projects/HC-00059_MERCEDES_RECORD" "/Volumes/offsite_backup/Backups/Inactive Projects/12_DEC_2022/"
2 Likes

I did a little testing using two words. One with smart quotes and one with straight quotes.

If the macro is run with the straight followed by smart (which is what your original data has), nothing is converted. Probably on the assumption that, since a straight quote was found, no conversion is necessary.

But if the macro is run with the smart quote followed by the straight quote, the conversion to straight quotes is done.

So it seems the filter has trouble processing mixed quotes.

@peternlewis?

Keyboard Maestro’s quote filtering coverts quoted pairs to new quoted pairs.

Your input test is a mish mash of smart and dumb quotes, and so the pairs are frequently not there. You've got smart opening quotes at the ends of lines for example.

Basically, garbage in-garbage out.

In this case, assuming all those smart quotes in random positions with random directions are just supposed to be converted to dumb quotes, you want to use a search & replace, not a filter.

3 Likes