• 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: shameless begging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shameless begging


  • Subject: Re: shameless begging
  • From: Emmanuel <email@hidden>
  • Date: Thu, 21 Sep 2006 14:29:40 +0200

At 7:44 AM -0400 9/21/06, Tom Burke wrote:
I'm running OS 10.4.7 on an intel-based iMac, with AppleScript 1.10.7. I am a complete novice so far as AppleScript goes, but I'm a quick learner if someone can get me booted in the right direction. Here is my problem:

I have a plain-text TextEdit file with N lines of ascii text. I need to write each of these N lines into its own file, using a file name based on the first few symbols on the respective line.

Might someone out there have a script that does this task?

-- untested!!!

set thePath to "Macintosh HD:Users:You:Documents:Whatever"
set theText to read (file thePath) -- a string
set theLines to paragraphs of theText -- a list of N strings

set theFolder to "Macintosh HD:Users:You:Documents:files:" -- the folder for the new files

repeat with theLine in theLines
set theLine to contents of theLine -- evaluate reference to item in list
set theBeginning to text 1 thru 20 of theLine -- will error is theLine is shorter than 20 chars
set theRefNum to open for access file (theFolder & theBeginning) with write permission -- this creates the file and returns a reference number to it
write theLine to theRefNum
close access theRefNum
end repeat


Emmanuel
_______________________________________________
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


References: 
 >iCal Script (From: "Jesse Almanrode - JA Computing" <email@hidden>)
 >shameless begging (From: Tom Burke <email@hidden>)

  • Prev by Date: Re: acrobat and applescript
  • Next by Date: Re: AppleScript runs slow on Intel Mac's
  • Previous by thread: shameless begging
  • Next by thread: Re: shameless begging
  • Index(es):
    • Date
    • Thread