Re: checking for characters
Re: checking for characters
- Subject: Re: checking for characters
- From: Nigel Garvey <email@hidden>
- Date: Wed, 10 Sep 2003 12:18:08 +0100
Tait Sanders wrote on Wed, 10 Sep 2003 12:00:55 +1000:
>
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 ...
(That may have been off list. It hasn't appeared in the digest.)
>
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
In your first post, you said you wanted to check the name of the folder.
Here you're trying to check the names of the items added to it.
'added_items' is an AppleScript list, not a Finder reference, so it
doesn't have a 'name'. You have to loop through the list:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this_item in added_items
set s to name of this_item
if s contains "." and s does not start with "." and s does not
end with "." then
delete this_item
end if
end repeat
end tell
end adding folder items to
If it's simply your intention that nothing whose name is in *.* format
should survive in the folder, you could do this, which is faster:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
delete (every item of this_folder whose name contains "." and
name does not start with "." and name does not end with ".")
end tell
end adding folder items to
('added_items' isn't actually used here, but an 'after receiving'
parameter is compulsory with this sort of handler.)
NG
_______________________________________________
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.