• 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: Joining text files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Joining text files


  • Subject: Re: Joining text files
  • From: John Delacour <email@hidden>
  • Date: Wed, 6 Nov 2002 13:28:18 +0000
  • Mac-eudora-version: 5.3a8

At 12:41 pm +0000 6/11/02, Steve Savery wrote:

I'm trying to join three text files into one. I've tried to use the open file method but it gives me garbage....


Provided the length of your files is not going to cause memory problems, something like the script below will create a concatenated file in the same folder as the joined files (your Documents folder). Otherwise a more elaborate routine is required.



-- Change << to opt-\ ; change >> to opt-shift-\

set basepath_ to "" & (path to <<constant afdrdocs>>) -- see NOTE ABOVE
set shortfiles_ to {"a.txt", "b.txt", "c.txt"}
set longfile_ to basepath_ & "concat.txt"
set filelist_ to {}
repeat with f in shortfiles_
set end of filelist_ to basepath_ & f
end repeat
open for access file longfile_ with write permission
set eof file longfile_ to 0
repeat with f in filelist_
open for access file f
try
set chunk_ to read file f
on error
close access file f
exit repeat
end try
close access file f
write chunk_ to file longfile_
end repeat
close access file longfile_
-- read file longfile_

-- JD
_______________________________________________
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.

References: 
 >Joining text files (From: Steve Savery <email@hidden>)

  • Prev by Date: Re: Problem with Spinning Progress Indicator
  • Next by Date: Re: How do I Read and Write a list to a file
  • Previous by thread: Joining text files
  • Next by thread: Real Simple Question
  • Index(es):
    • Date
    • Thread