-- Rename for Dropbox-Windows -- https://c-command.com/scripts/eaglefiler/rename-for-dropbox-windows -- Summary: Changes filenames for better interoperability with Dropbox and Windows. -- Requires: EagleFiler -- Install Location: ~/Library/Scripts/Applications/EagleFiler/ -- Last Modified: 2022-09-07 tell application "EagleFiler" set _records to selected records of browser window 1 repeat with _record in _records set _record's filename to my processName(_record's filename) set _record's basename to my processBaseName(_record's basename) end repeat end tell on processName(_name) set _invalidChars to "<>/\\|:" repeat with _c in _invalidChars set _name to my replace(_name, _c, "-") end repeat set _cr to ASCII character 13 set _lf to ASCII character 10 set _invalidChars to "\"?*" & _cr & _lf repeat with _c in _invalidChars set _name to my replace(_name, _c, " ") end repeat set _name to my replace(_name, "↔", "<-->") -- left right arrow Unicode 034D set _name to my replace(_name, "↔", "<->") set _name to my replace(_name, "➝", "-->") -- rightwards arrow Unicode 2192 set _name to my replace(_name, "➝", "->") set _name to my replace(_name, "←", "<--") -- leftwards arrow Unicode 2190 set _name to my replace(_name, "←", "<-") set _name to my replace(_name, "⇔", "<==>") -- left right double arrow Unicode 21D4 set _name to my replace(_name, "⇔", "<=>") set _name to my replace(_name, "⇒", "==>") -- rightwards double arrow Unicode 21D2 set _name to my replace(_name, "⇒", "=>") set _name to my replace(_name, "⇐", "<==") -- leftwards double arrow Unicode 21D0 set _name to my replace(_name, "⇐", "<=") set _name to my replace(_name, ">", ">") -- fullwidth greater-than sign Unicode FF1E set _name to my replace(_name, "<", "<") -- fullwidth less-than sign Unicode FF1C set _name to my replace(_name, "?", "?") -- fullwidth question mark Unicode FF1F set _name to my replace(_name, "*", "*") -- fullwidth asterisk Unicode FF0A set _name to my replace(_name, "/", "/") -- fullwidth solidus Unicode FF0F set _name to my replace(_name, "\", "\\") -- fullwidth reverse solidus Unicode FF3C set _name to my replace(_name, "|", "|") -- fullwidth vertical line Unicode FF5C set _name to my replace(_name, ":", ":") -- fullwidth colon Unicode FF1A set _name to my replace(_name, """, "\"") -- fullwidth quotation Unicode FF02 set _name to my removeTrailingSpaces(_name) return _name end processName on processBaseName(_name) set _name to my replace(_name, ".", "-") set _name to my removeTrailingSpaces(_name) return _name end processBaseName on replace(_string, _source, _replacement) set AppleScript's text item delimiters to _source set _items to every text item of _string set AppleScript's text item delimiters to _replacement return _items as Unicode text end replace on removeTrailingSpaces(_string) set AppleScript's text item delimiters to "" repeat until _string does not end with " " set _string to (characters 1 thru -2 of _string) as Unicode text end repeat return _string end removeTrailingSpaces