I would assume that you want to strip these characters before the file goes on a Windows- or Unix-compliant server, right? (If these were in fact illegal characters on a Mac system, the only ones where you could do an Applescript, then the system itself (the "Finder" would already block it. )
How about a folder where all files to transfer get dropped, with a folder action script that will look at each name as it comes in and either a) strip the character, b) replace the offending character with a dummy, like an underscore, or c) put up a dialog asking whether the "puttee" wants to rename the file to something else.
Such a script would be a bit long to post here. Check the AppleScript Users mail list (from the Apple Web site) if you would like help writing such a filter.
Here is a sample script to get you started. Copy this, paste into Script Editor, and compile (watch out for line breaks that wrap here but aren't supposed to!) Save as a "Script Application". The script application will take a file dropped on it and replace any spaces in the name with underscores. You can modify the first "AppleScript text item delimiters" line to any other character that is giving you problems, and replace the underscore in the second text item delimiter line with any other replacement character you want. You can also just stack up a series of replacements and do them all at once.
Once you get that working (on a sample file named using all the wild characters you expect to encounter), you have to negotiate the following: 1) accessing and changing the names on the server (possibly by copying to your desktop, deleting from the server, changing the names and copying back) and 2) setting up a repeat loop that will handle not only a number of files but the possibility of nested folders as well. Again, that can be lengthy, so I suggest you post the question to the AppleScript Users List, accessible from the AppleScript home page.
----- script begins. Watch for broken line wraps!
on open (somefile)
tell application "Finder"
set SomeName to name of somefile
set name of somefile to my replaceThisText(SomeName)
end tell
end open
on replaceThisText(Incoming)
--recognize divisions by spaces
set AppleScript's text item delimiters to {" "}
copy every word of Incoming to Outgoing
set AppleScript's text item delimiters to {"_"}
--put words back together divided by underscores
set Outgoing to Outgoing as string
--reset divisions to default for any other scripts
set AppleScript's text item delimiters to {""}
return Outgoing
end replaceThisText
There was just a thread on this kind of topic at the AppleScript user's list in the last week. Sign up through applescript.com and check the archives -- you may find just the ticket already developed for you!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.