• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking if a folder exists and dealing with it
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Checking if a folder exists and dealing with it
      • From: César Escolar <email@hidden>
    • Re: Checking if a folder exists and dealing with it
      • From: Thomas <email@hidden>
References: 
 >Checking if a folder exists and dealing with it (From: Chad Chelius <email@hidden>)

  • Prev by Date: Re: Check if it is a number
  • Next by Date: Re: Checking if a folder exists and dealing with it
  • Previous by thread: Checking if a folder exists and dealing with it
  • Next by thread: Re: Checking if a folder exists and dealing with it
  • Index(es):
    • Date
    • Thread