I have a script that I use to manipulate the names of the files
within a folder. I want the names to be word capitalized, all underscores
changed to spaces, and optionally, based on an input response,
the first word of the name uppercased.
The script works as advertised. It's the manipulation of the text
that I have a question about.
Currently, I get the text that represents the filename, and call a handler
to massage this text. This is done (using Tex-Edit Plus, my particular
text editor of choice), by opening a new document, dropping in the text,
making the changes, collecting the changed text, and discarding the
created document, and returning the changed text to the caller of
the handler.
While this works, it seems extremely cumbersome, and is slow.
Here's the handler:
on word_cap(the_text, upcase_word1)
tell application "Tex-Edit Plus"
set temp to "temp"
make new document with properties {name:temp}
tell window temp
copy the_text to before first character
set capitalization of line 1 to word caps
replace line 1 looking for "_" replacing with space
if upcase_word1 then set capitalization of word 1 of line 1 to uppercase
set upcase to line 1 as text
close saving no
end tell -- window temp
end tell -- Tex-Edit Plus
return upcase
end word_cap
Please tell me there is a better, easier way to be able to manipulate text
in AS without having to go through these gyrations.
TIA,
Jim Brandt
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives:
http://lists.apple.com/archives/applescript-users
This email sent to email@hidden