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
Description
This script changes the filenames of the selected records to replace characters that are invalid on Windows with spaces and hyphens. See also the user-contributed script and smart folder in the forum.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
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