• 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
creating a file within a folder etc...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

creating a file within a folder etc...


  • Subject: creating a file within a folder etc...
  • From: Jean-Christophe Helary <email@hidden>
  • Date: Mon, 21 Feb 2011 07:58:01 +0900

First, thank you to all the people who replied to my request for a paper reference hint. I've browsed though a few of them already and I'll make a decision soon.


Now, what I am trying to do (closest to the AS way as possible) is the following:

1) ask the user to specify a location
2) create a folder in that location
3) create a file in that folder
4) fill that file with data

What I ended up with is the following code:

========================
set project_location to choose folder
set project_name to display dialog
set project_name to text returned of project_name

tell application "Finder"
	set project_folders to make folder at project_location with properties {name:project_name}
	set parameters_path to (make file at project_folders with properties {name:"parameters.txt"}) as text
end tell

set parameters_data to "whatever"

set parameters to open for access file parameters_path with write permission
write parameters_data to parameters
close access parameters
========================

Is there an easier way to do that ?
Is there a more ASly way to do that ?

It took me a huge lot of time to find the correct syntax for:

set parameters_path to (make file at project_folders with properties {name:"parameters.txt"}) as text

But I a not sure why is the current syntax correct. Why does "set something to (make file) as text"  generate a useable path?

My understanding is that "make file" is specific to Finder, am I correct ? Is there a way to not "tell Finder" to create a file and use a more generic way instead ?


Jean-Christophe Helary
----------------------------------------
fun: http://mac4translators.blogspot.com
work: http://www.doublet.jp (ja/en > fr)
tweets: http://twitter.com/brandelune

 _______________________________________________
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: creating a file within a folder etc...
      • From: Shane Stanley <email@hidden>
    • Re: creating a file within a folder etc...
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Help Unsubscribe
  • Next by Date: Re: mdls & .app?
  • Previous by thread: Re: Help Unsubscribe
  • Next by thread: Re: creating a file within a folder etc...
  • Index(es):
    • Date
    • Thread