• 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: reading a file in an applescript.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading a file in an applescript.


  • Subject: Re: reading a file in an applescript.
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 21 Mar 2008 15:44:57 -0400

On Fri, Mar 21, 2008 at 3:35 PM, Doug Meade <email@hidden> wrote:
>
>  Hi folks!
>  New to applescript ...
>  I'm trying to read a file in an applescript.
>
>  I've tried a number of different syntax options.
>  The most simple is:
>
>  read theTextFile

Welll, that won't work, first of all, but what is the value of
"theTextFile"?  Are you setting it to a file name, an alias, the
result of an open for access call, or what?

Here's a model:

set targetFile to (choose file with prompt "Pick a file")
set readHandle to (open for access targetFile)
set fileText to (read readHandle for (get eof readHandle))
close access readHandle
fileText

If you have a filename you want to read, instead of prompting the user
for the file interactively, then you should

set targetFile to file "Macintosh HD:this:is:where:it:is:foo.txt"

or

set targetFile to POSIX file "/this/is/where/it/is/foo.txt"

the rest is the same.
--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: reading a file in an applescript.
      • From: Christopher Nebel <email@hidden>
    • Re: reading a file in an applescript.
      • From: Doug Meade <email@hidden>
References: 
 >reading a file in an applescript. (From: Doug Meade <email@hidden>)

  • Prev by Date: Re: mounting volumes
  • Next by Date: Re: Number Format Problem
  • Previous by thread: reading a file in an applescript.
  • Next by thread: Re: reading a file in an applescript.
  • Index(es):
    • Date
    • Thread