Re: script to delete .html files from a folder
Re: script to delete .html files from a folder
- Subject: Re: script to delete .html files from a folder
- From: Courtney Schwartz <email@hidden>
- Date: Fri, 5 Nov 2004 12:20:04 -0500
This seems to be one of the most common errors... presenting a string
that contains a path, instead of a file alias data type (Finder uses
file aliases, not strings). Hence Michelle's coercion "as alias".
Because AppleScript is so English-like, it's easy to forget that you're
still restricted by passing the expected data types into
functions/methods/handlers... In English, the abstraction is much more
obvious than it is to a computer. :)
Personally, I tend to keep my path variables as strings (so they're
ready to do regex etc.), then coerce them as necessary, but I suppose
it's just as easy to argue for the other way around... depends which
operations on your path are more common to save you processing time...
Courtney Schwartz
On Nov 5, 2004, at 12:09 PM, Michelle Steiner wrote:
On Nov 5, 2004, at 9:08 AM, Roger Donaghy wrote:
This script compiles without a problem, but when I run it, I get the
following error:
Finder got an error: Can't get item 3 of folder "Macintosh
HD:Users:rdonaghy:Documents:testScript:".
That's because by the time the script gets to item 3, there are fewer
than 3 items left in the folder. In cases like this, you should
remove from the end, working backwards.
Any help would be greatly appreciated.
Try this script instead:
set ThePath to (path to documents folder as string) & "testScript" as
alias
tell application "Finder"
move (files of ThePath whose name extension is "html") to the trash
end tell
--
Help, I've caught a cult, and can't get out!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________
Courtney Schwartz
Documentation Specialist
Global Technology Associates
3505 Lake Lynda Dr. Suite 109
Orlando, FL 32817 USA
(407) 380-0220 x1427
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden