

(The Save dialog box, as you know, lets you specify a name for the document and where you want it stored.) 5.7.2. If you haven't saved your current TextEdit document yet, a Save dialog box appears. Thus, if you needed a script to save your current TextEdit document, this one would work well: tell application "TextEdit" activate save the front document end tell If you'd rather just replace the existing codes with new ones, check out for a list of type and creator codes for different programs and files.Īs the epitome of Mac-ness, TextEdit does support the save command.
DIALOG MAKER APPLESCRIPT MAC OS X
If you'd like to banish the type and creator code from a fileso that Mac OS X will judge the file by its extensionenter "?" for both codes (or, if you want the details of erasing such codes, see ). New:" default ¬ answer "") -Set the new type and creator codes: tell application "Finder" set the file type of ¬ selectedFile to newF set the creator type of ¬ selectedFile to newC end tell New:" default answer "") set newC to text returned of ¬ (display dialog "Current creator ¬ code: " & cType & ". Set selectedFile to (choose file) (* Get the file's current type and creator codes: *) tell application "Finder" set fType to the file type of ¬ selectedFile set cType to the creator type of ¬ selectedFile end tell (* Get the new type and creator codes you want to use: *) set newF to text returned of ¬ (display dialog "Current type code: " ¬ & fType & ". Thankfully, AppleScript lets you modify type and creator codesor get rid of them completely. That's why the help files that come with Photoshop won't open in your default Web browser: Adobe has set their creator code to "MSIE," so they'll always open in Internet Explorer. In fact, if a file has a type and creator code, they override any settings for which program should open the file. The importance of type and creator codes in Mac OS X is reduced, but they're still around. A file created with Photoshop would use the creator code "8BIM," while one created with AppleWorks would use "BOBO"go figure. The creator code, on the other hand, told your Mac which program produced a file. For example, if a file's type code was "TEXT," that meant the file was just plain text, while a type code of "APPL" meant the file was an application. The type code told your Mac what kind of information was stored in a file. To see if a particular program supports AppleScript-based saves, open the program's dictionary and see if the dictionary's Standard Suite (Section 3.2.3) includes the save command.īack in the days of Mac OS 9, before you had to put file extensions at the end of documents' names, your Mac knew what kind of files you had by their type and creator codes. Unfortunately, this trick works only in certain programs (TextEdit, Microsoft Word, and Safari, for example). Similarly, the save as command works the same way as choosing File Save As (that is, when you provide a file path to the save as command, Mac OS X saves a copy of your current file in the location you specify). AppleScript makes this simple: the save command works the same way as choosing File Save. The last piece of the Mac OS X file puzzle is saving documents you already have open.
