Re: Weeding out words
Re: Weeding out words
- Subject: Re: Weeding out words
- From: Brett Conlon <email@hidden>
- Date: Fri, 9 Feb 2007 13:26:11 +1000
Hiya Tim,
My script later on adds the words "Collection"
or "Box Set Collection" or "Season" or "Triple
Pack" etc. When the user is prompted to enter the movie title's name,
if they didn't just stick with the movie title and added the words "Box
Set" or "boxset" or whatever, there would be double-ups
in the file name later. The cleanup script trims any of these out first.
Here's what I ended up using. A big
thanks to Matthew and Malcolm for offering their advice which helped me
to get it working very nicely:
set
TitleAns to
"My Movie Title Special Box Set Boxset"
set
Offenders to
{"Special", "Edition", "SE", "Box Set",
"Boxset", "Box", "Set"} -- words which
need to be stripped if the user entered them by mistake.
set
TitleAns to
my
CleanupTitle(TitleAns, Offenders)
on
CleanupTitle(TitleAns, Offenders)
set
wordList to
every
word of
TitleAns
set
TitleAns to
{}
repeat
with
oneWord in
wordList
if
oneWord is
not in
Offenders then
set
end
of
TitleAns to
oneWord's contents
end
if
end
repeat
set
OldDelims to
AppleScript's text item delimiters
set
AppleScript's text item delimiters to
{" "}
set
TitleAns to
TitleAns as
string
set
AppleScript's text item delimiters to
OldDelims
return
TitleAns
end
CleanupTitle
Cheers,
Cojcolds
Tim Mansour <email@hidden>
09/02/07 02:02 PM
|
To
| Brett Conlon <email@hidden>
|
cc
| email@hidden
|
Subject
| Re: Weeding out words |
|
On 08/02/2007, at 5:38 pm, Brett Conlon wrote:
> set TitleAns to "My Collection box set asset boxy dog box
> collection is here" -- some example text returned in a user dialog
> set Offenders to {"collection", "box", "set",
"boxset"} -- words
> which need to be stripped if the user entered them by mistake.
Um ... is it just me, or does this seem like a strange thing to do?
When asking for a text response from the user they can write
absolutely anything they like. So shouldn't you be looking for words
that are legal, rather than removing ones that aren't?
--
Tim Mansour <email@hidden>
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden