dharple / detox

Tames problematic filenames
BSD 3-Clause "New" or "Revised" License
332 stars 19 forks source link

How to ignore Icon␍ macOS files? #94

Closed b-g closed 2 years ago

b-g commented 2 years ago

Many thanks for this great tool!! 🙏 (Not an issue, rather a question.)

Following carefully the great documentation I manged to write a custom sequence to make filenames safe for exFAT formatted volumes. Great! Now just I have trouble with macOS Icon␍ files.

My .detoxrc looks like below ... but I couldn't figure out how to set the ignore filename parameter correctly to actually ignore the macOS Icon␍ files. Some attempts:

sequence exfat_safe {
   safe {filename "/Users/bene/.detox/exfat_safe.tbl";};
};

ignore {
   filename "Icon?";
   filename "Icon␍";
   filename "Icon\0x0D";
   filename "Icon[\r]";
};

Any hints how to achieve this?

dharple commented 2 years ago

The detoxrc perser is just looking for a string, so you can't use a shell wildcard, a C escape sequence, or a regex bracket expression.

You can, however, just insert an actual Control-M into the string. It gets really weird, because Control-M affects the way the console works.

$ tail /tmp/detoxrc.sample 

ignore {
    filename ".arch-params";
    filename ".evolution";
    filename ".gnome";
    filename ".mozilla";
    filename ".themes";
    filename "{arch}";
";  filename "Icon
};

Note that the closing quote now appears to be at the start of the line.

Anyway, you should be able to cut and paste it out of this: detoxrc.zip . I tested it to confirm that it will work.

$ mkdir /tmp/test
$ cd /tmp/test
$ touch $(printf "Icon\r") 
$ ls
'Icon'$'\r'
$ detox -f /tmp/detoxrc.sample -nv .
Scanning: .

With the original config file:

$ detox -nv .
Scanning: .
 -> ./Icon_

Note that the original filename in the example above is overwritten due to the Control-M in the filename resetting the cursor position to the start of the line.

dharple commented 2 years ago

And thank you for the compliment!

b-g commented 2 years ago

Hi @dharple, Sorry for slow response! Had a little internet detox in the Alps :)

Many thanks for the solution! This works!

For others coming across this esoteric issue: I couldn't copy and paste the magic Control-M line in my normal code editors e.g. Sublime Text and had to try out a few other editors ... for some weird reason just macOS on-board TextEdit manged to do the trick for me. 🤷