Opening text file with TextEdit

Hi Again!

We work with template files for our digital press. They are .jlt files, which of course, the MAC doesn’t recognize as an editable file really. I have a script that goes out on the network, searches a specific folder for a file called “XXXXXX.jlt” where the X’s represent a job number. If the script finds a matching file, it copies it to the desktop.

I would like to extend the capabilities of this script to actually open the .jlt file using textedit, search for a specific string and alter that string, then save the file under a new job number.

On OS-Ventura I have the file copying:

copy file ThisJob to desktop

but when I try to open it,

tell application “TextEdit”
activate
open “Macintosh HD:Users:proofdepartment:Desktop:” & JobNum & “.jlt”
end tell

I get a error dialog that says the file can’t be opens because I don’t have permission. If I click the ok button on that error, then go to my desktop and drop that file directly onto TextEdit, it opens it without a problem.

Is there some other way I can open the .jlt file and not get this error?

thanks
David

Try the following.

set JobNum to "12345" -- just for testing
set theFile to ("Macintosh HD:Users:proofdepartment:Desktop:" & JobNum & ".jlt") as alias

tell application "TextEdit"
	activate
	open theFile
end tell

Try this, the Desktop folder is the root folder of the Finder

set fileName to (JobNum as text) & “.jlt”
tell application "Finder"
    open file fileName using application file id "com.apple.TextEdit"
end tell