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: "Adam K. Wuellner" <email@hidden>
- Date: Fri, 5 Nov 2004 10:42:24 -0600
On Nov 5, 2004, at 10:08 AM, Roger Donaghy wrote:
tell application "Finder"
set thePath to (startup disk as text) &
"Users:rdonaghy:Documents:testScript:"
set theCount to count of items in thePath
if theCount > 0 then
repeat with i from 1 to theCount
set theFileName to item i in folder thePath
set theFileNameText to the name of theFileName as text
if the name extension of theFileName is equal to "html" then
move file theFileNameText in folder thePath to trash
end if
end repeat
end if
end tell
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:".
Does anyone know the cause of this error? Any help would be greatly
appreciated.
Here's an approach that works on my machine:
set thePath to (path to startup disk as text) & "Users:akw:Desktop:"
tell application "Finder"
set HtmlFiles to files of folder thePath whose name extension is "html"
move HtmlFiles to trash
end tell
Note that I put the (path to startup disk) outside of the Finder tell
block, since it's a scripting addition command and you don't want to
stuff application tell blocks full of stuff that doesn't absolutely
need to be there. It also takes advantage of a whose clause to get
only the html files immediately, and just moves that list to the trash.
HTH,
Adam
_______________________________________________
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