Re: if clauses: multiple values in one test?
Re: if clauses: multiple values in one test?
- Subject: Re: if clauses: multiple values in one test?
- From: Mikael Byström <email@hidden>
- Date: Sun, 21 Sep 2003 15:03:16 +0200
Paul, email@hidden said:
>
Before we leave the topic, are you sure you shouldn't be doing this in the
>
Finder using its 'name extension' property (or name property) if that's what
>
you're actually looking for?
Well, I am doing this in the finder and name extensions is what I want to
use. I wasn't aware of this property however. So thank you.
The whole script, a folder action intended to trash files with "bad" file
extensions in my email attachments folder became with your suggestions:
***
on adding folder items to this_folder after receiving added_items
set BadFileEndings to {"html", "vcf", "pif", "bat", "scr", "exe", "wmf",
"pcx"}
tell application "Finder"
try
-- set the folder
set DownloadsFolder to (folder (this_folder as alias))
set theFileList to the items of DownloadsFolder
-- repeat this section of the script with all files in the file list
repeat with oneItem in theFileList
set FileEnding to name extension of oneItem
set FileName to name of oneItem
if ({FileEnding} is in BadFileEndings) or (FileName begins with
"enclosure") then
move oneItem to the trash
end if
end repeat
on error
beep
end try
end tell
end adding folder items to
***
One funny thing is that the active finder window blinks at the end of
execution. Any idea what that is and how to remove it?
I realize I really should be testing only the newly added items and not
all the contents of the folder. But I'm not sure how to get that subset.
Suggestions? I did try refering "added_items", but that didn't work.
Any other suggestions on how to speed this script up (within the AS
domain) are equally welcome.
Another question: How do I debug (with Script Debugger) a folder action?
This time I first tested with the current folder and added the folder
action parts in the end. Are there other ways?
_______________________________________________
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.