Re: Checking if a folder exists and dealing with it
Re: Checking if a folder exists and dealing with it
- Subject: Re: Checking if a folder exists and dealing with it
- From: Mr Tea <email@hidden>
- Date: Wed, 04 Dec 2002 17:09:31 +0000
This from Chad Chelius - dated 04-12-02 01.17 pm:
>
How can I put error trapping into my script so that if
>
this folder does exist, it will simply skip over it and go to the next one.
>
>
make new folder in every item of ShortFoundTemplateMatches with properties
>
{name:"Templates"}
A repeat loop is probably needed here. Replace the above section of your
script with:
set theFolders to every folder of ShortFoundTemplateMatches
repeat with aFolder in theFolders
try
make new folder at aFolder with properties {name:"Templates"}
end try
end repeat
... this assumes that you are working in a Finder tell block, and that your
variable is a list of aliases or references to Finder items. For more robust
error checking that will deal with cases when the error is not caused by the
existence of an item with the same name, you could do this:
set theFolders to every folder of ShortFoundTemplateMatches
repeat with aFolder in theFolders
try
make new folder at aFolder with properties {name:"Templates"}
on error errmsg number errnum
if errnum is not -48 then display dialog errmsg
end try
end repeat
As before, that needs to be inside a Finder tell block.
HTH
Mr Tea
_______________________________________________
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.