I’m helping a nonprofit use OneDrive on their Macs, and we occasionally get the problem of illegal file names, since *nix systems are more tolerant of non-alphanumeric characters. Mac sees perfectly valid file names, where NTFS-centric OneDrive won’t accept them. I know the regex I want to substitute with spaces or underscores:
[/\\:*?"<>|_]+
And I’ve found a couple scripts that do something similar:
Exhibit A, but it is too old and throws errors. Maybe it could be tweaked?
Exhibit B, but it leaves a lot of undesirable characters and seems to focus on white space.
In short, I need to deliver an executable shell script or Applescript that cleans out most of the stuff Windows won’t tolerate in a filename. Microsoft’s answer is to basically uninstall/reinstall/reset, but it happens too often to consider this a viable fix. Any script heroes out there?