• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: checking for characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking for characters


  • Subject: Re: checking for characters
  • From: "Marc K. Myers" <email@hidden>
  • Date: Wed, 10 Sep 2003 13:03:23 -0400

Date: Wed, 10 Sep 2003 12:00:55 +1000
Subject: Re: checking for characters
From: Tait Sanders <email@hidden>
To: email@hidden

On Wednesday, September 10, 2003, at 10:34 AM, Christopher Nebel wrote:
set s to name of folder b
if s contains "." and s does not start with "." and s does not end
with "." then ...

contains "." is fairly obvious; if that's true and the first and last
characters are not dots, then there's something on either side. This
doesn't detect the presence of multiple dots, but then neither would
the regular expression "*.*".

Also, realize that AppleScript, by itself, doesn't know how to delete
files, so you'll have to tell the Finder to do that. (Or use "do
shell script" with "rm", if you're into that sort of thing. Using the
Finder is easier, though.)

I tried this and to me it looks like it should work... but it
doesn't.... I'm a newbie at Apple scripting... what am I doing wrong
here?

on adding folder items to this_folder after receiving added_items

tell application "Finder"
set s to name of added_items
if s contains "." and s does not start with "." and s does not end with
"." then
delete added_items
end if
end tell

end adding folder items to

Your problem here is that "set s to name of added_items" returns a list of aliases, not a single alias. Lists don't have names. You have to look at the items of that list (even if there is only one) and extract the name from each alias. Something like this:

on adding folder items to this_folder after receiving added_items

repeat with anAlias in added_items

tell application "Finder"
set s to name of anAlias
if s contains "." and s does not start with "." <line break>
and s does not end with "." then
delete anAlias
end if
end tell

end repeat

end adding folder items to

Marc [09/10/03 1:01:28 PM]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: iCal & AppleScript
  • Next by Date: Re: Calling a script object
  • Previous by thread: Re: checking for characters
  • Next by thread: Re: Re: Dates gone wild [correction]
  • Index(es):
    • Date
    • Thread