Re: Renaming files/folders
Re: Renaming files/folders
- Subject: Re: Renaming files/folders
- From: Michelle Steiner <email@hidden>
- Date: Wed, 5 Sep 2001 06:29:32 -0700
On 9/4/01 11:31 PM, Ray Phillips <email@hidden> wrote:
>
I've written a script for a droplet which alters the names of any files and
>
folders (and their contents) which are dragged onto it so the become valid
>
for a FAT file system. (It removes any trailing spaces and periods, and
>
replaces any of these characters \ / * ? \ " < > | with '-'.)
That shouldn't take a 200-line script. Here's a much shorter one that
should do what you need. I haven't tested it, though.
--Michelle
on open (DroppedItems)
set the filestochange to the files of the DroppedItems
repeat with thisFile in filestochange
tell application "Finder"
set the NameToChange to the name of thisFile
end tell
set tid to text item delimiters
change(NameToChange, "\\")
change(NameToChange, "/")
change(NameToChange, "*")
change(NameToChange, "?")
change(NameToChange, "\"")
change(NameToChange, "<")
change(NameToChange, ">")
change(NameToChange, "|")
set text item delimiters to tid
tell application "Finder"
set the name of thisFile to the NameToChange
end tell
end repeat
end open
on change(inString, inChar)
set text item delimiters to the inChar
set tempList to text items of the inString
set text item delimiters to "-"
set the outstring to tempList as text
return the outstring
end change
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------