Hello all- I have ran into a problem that I hope has a easy fix to it that someone can help with. Here we go- I need to be able to open a document in Tex-Edit Plus (ver 4.1.2), copy the entire contents into a new document, do a little text replacement and save that new document in a folder with a new name. I can get it to do it with user intervention, but that is the problem. This script is going to be running in a repeat loop with several hundred files, and after the new page is made I need it to “save as” with a variable name that will change each time through the loop. I would like to be able to choose the destination folder once at the start of the script, and have all remaining files show up in that folder. Can it be done in Tex-edit? Or do I need another editor that can replace text. I have included the script that I have been working on, but when I run it I get the message “Tex-Edit Plus got an error: Duplicate file name. Some object”. I made sure that there is not a file with the same name in that location. I hope this is enough info for the problem. Thanks for any help in advance.
John
tell application "Finder"
set pathname to "P113 G4:Desktop Folder:test file" as string
end tell
--pick a folder to store the file into set folderpath to choose folder with prompt "Select the destination folder:"
--the file name variable set fileName to "Anewtestfile"
tell application "Tex-Edit Plus"
open file pathname
copy every character of file pathname as list to templist
make new window with properties {name:fileName} with data (contents of window 1 as styled text)
select insertion point before character 1 of front window
close window 2 saving no
save window 1 in folderpath
end tell