The “do shell script” command is for incorporating command-line apps when you simply don’t have a Mac app to do the job, for example, you can do regex stuff with Perl. The “open for access” command is a last resort for reading and writing files that you simply don’t have an app to read or write. You simply tell Photoshop to open the PNG image and export it as a JPEG to a particular file location. If you want to convert a PNG to a JPEG, you don’t write a PNG decoder and JPEG encoder in AppleScript and open the PNG file for access and read it byte by byte and then encode a JPEG byte by byte. The most fundamental feature of AppleScript is sending messages to Mac apps in this way. For example, the text content could come from another app or the clipboard, and the text file could be opened in another app or emailed after it is saved. The advantage of this method is it is faster and easier to write, it is less error-prone, the text file that you get as output has the same properties as text files that you create manually with TextEdit, and your script can now be easily expanded to include other apps. Save document 1 in file (theDesktopPath & "file.txt") Set theDesktopPath to the path to the desktop folder as text
How to make an srt file with apple textedit how to#
TextEdit knows how to do that without generating file access errors (like open for access) or accidentally overwriting folders (like shell scripting.) tell application "TextEdit" All you have to do is ask TextEdit to make you a text document with whatever contents you like and and save it wherever you like. You don’t have to use (error-prone) shell scripting.
You don’t have to use (error-prone) open for access.
It already knows how to create and save text documents without generating errors.
The way you can avoid errors when writing text with TextEdit is to remember that it is a text editor.