Merging Tex-Edit Plus Files

Hi. I am very new to AppleScript, but I have heard great things about it and this board. I am trying to find a way to merge about 100 Tex-edit files into one large file which I could then import to Quark. Does anyone know how to do this? Thanks in advance.

Hi Emperor Ent,
Whoever could do something like this may have a few questions. Like how would you merge these files together (sorted by name, date created, date modified, etc., backwards)? Would you make a droplet or do you want to choose the folder that contains the files or both?
BTW. Did you know that Tex-Edit Plus is very recordable? You can open the Script Editor and press the record button then run Tex-Edit open a new Tex-Edit document and start inserting a few files. When you see a pattern emerging, you can put that into a repeat loop. This is a way to begin learning how to write AppleScripts. Later, you’ll find that there are many shortcuts to what you get from recording, but, it’s a good beginning.
Later, Kel.

Thanks. Well a droplet would probably be best, something that a folder could be dropped into and as for the order, I guess alphabetical would be best. I’ll also see what I can do on my own with Tex-Edit and recording. Thanks again.

Hi,
Maybe you can look through this and fix it up how you want.
<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>
on open the_list – assume 1 folder in this list of references
set folder_path to the_list as string – coerce the list to a path
set item_list to list folder folder_path ¬
without invisibles – get a listing of names of all the items
– where to put all the files?
set item_list to ASCII_Sort(item_list) – sorts alphabetically
tell application “Tex-Edit Plus”
launch – launches Tex-Edit without the intial window
make new window at front
end tell
– go through the list
repeat with i in item_list
set item_path to (folder_path & i) – concatinate folder path and item’s name
set item_info to info for item_path – returns information about this item
if (not folder of item_info and not alias of item_info) then
– assumes Tex-Edit can read all the files
tell application “Tex-Edit Plus”
set selection to return – add a return
insert contents of file item_path
set selection to return – add a return
end tell
end if
end repeat
– what to do with this thing that you’ve created?
set file_spec to file (folder_path & “Merged Files”) – make file specification
tell application “Tex-Edit Plus”
save front window in file_spec
quit – if it was already open and windows were open it will ask you to save
end tell
end open
– from AppleScript Guidebook, Sorting Routines
on ASCII_Sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to “”
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is “” then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end ASCII_Sort
Good Luck
ps. I tried not to use the “Finder”. :slight_smile:

I admit I don’t do any Quark scripting, but do you need to merge the files first? Can’t Quark import/append to an existing text box?

Awhile back Rob Day posted a question about how to make a script that would import multiple files into a single Quark document. I was hoping for a way to do the same thing. However, since Rob’s problem seemed unsolved, it seems that it might be easier to merge multiple documents and then import the one to Quark. I will try what Kel said but I continue to more than bumble through the confusing, but clearly useful world of AppleScript. Are you sure your script will work? Thanks again and in advance.