• 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: The Save command will replace, without asking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The Save command will replace, without asking


  • Subject: Re: The Save command will replace, without asking
  • From: Dave Lyons <email@hidden>
  • Date: Fri, 7 Oct 2005 18:39:53 -0700

On Oct 7, 2005, at 2:30 PM, Robert Poland wrote:
set targetfolder to "iMac HD:Users:rpoland:Desktop:"
...
if myfilename is in name of files of targetfolder then

-- error here Can't get every file of "iMac HD:Users:rpoland:Desktop:"

Any clues?

The trouble is that "targetfolder" is just a string, not a folder. (Sure, it has "folder" in its name, so you and I know it's supposed to refer to a folder, but the Finder doesn't know that.) Adding the word "folder" (or "item") makes it work as intended:


	... name of files of folder targetfolder ...


However, this method of checking file existence can be slow, if there are a large number of items in the folder (because Finder must build & return a list of the names of all the items). Here's another way, using "exists":


	tell application "Finder"
		if item myfilename of folder targetfolder exists then ...
	end tell

Cheers,

--Dave

_______________________________________________
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


  • Follow-Ups:
    • Re: The Save command will replace, without asking
      • From: "Gary (Lists)" <email@hidden>
References: 
 >Re: The Save command will replace, without asking (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: To Matt: Problem Sending AppleScripts as Text: The Resource Fork
  • Next by Date: Re: long shot..
  • Previous by thread: Re: The Save command will replace, without asking
  • Next by thread: Re: The Save command will replace, without asking
  • Index(es):
    • Date
    • Thread