3

When saving a script in Applescript Editor, it defaults to the Script file format. The file produced is binary and cannot be indexed by Spotlight. So if I want to search a script based on a word used in the code, I cannot since script code is not indexed.

On the other hand I can save as text, but I must remember to change the format option every time!

So what is the advantage of saving in Script format and is it possible to make Text the default?

I am using the editor in 10.6.8 Snow Leopard

EDIT:

Text format files are saved with the extension .applescript and are setup to open by default with the Applescript Editor, same as with .scpt.

1

This has been a goal for many an Applescripter for a long time.

Not sure anyone has hit the holly grail without using a third party scripting app with a Spotlight indexer..

I have tried a few things in the past but this thread prompted me again to have another go.

I now normally try and save all my applescripts in one places, in a Scripts folder in my Documents folder and also use Hazel to watch place like my Documents folder and desktop for scpt files and move them into the Scripts folder.

My new idea is to run a shell script that will be passed a scpt file that is saved in my Normal scripts folder as a normal scpt file and use the shell command osadecompile to decompile and read the file. Then create a text version in my new Script Text folder.

The code I am using is:

fname=`basename "$1"`

echo "`osadecompile "$1"`"  > "/Users/UserName/Documents/Scripts/Script Text/$fname".txt

Hazel conveniently uses $1 for the file path of the file being passed. And I use the command basename to get the file name.

In Hazel it looks like this.

enter image description here

Notice I am using a date last modified condition with 5 minutes.

This is to try and catch any edits I do.

The nice thing I found is when I find the text file with the code I am looking for, I can either copy the text, refer to it, or find the scpt file easily because I have the same file name in the text file file name.

i.e

display iTunes artwork.scpt

display iTunes artwork.scpt.txt

This idea should be able to be used with other folder watching apps or hopefully give you some inspiration ...

0

I can think of two:

  1. Extension names are meant to be associated with your application of choice. If you change your applescripts to be the default .txt app, you will be either opening up plain text with AppleScript Editor, or opening up applescripts with TextEdit when you double click. Of course you can resort to context menu, but some may consider it an nuisance.

To take it further, an user can save all his files without any extension, and scroll through all his applications from Adobe Photoshop to VLC everytime, ad absurdum.

  1. In less likely cases, an app needs the extension to know what to do with the file. For instance, TextMate can automatically apply the correct syntax highlight for .scpt files, and BetterTouchTool has an option to "Open Application, File, Apple Script". If the script is saved as .txt, it will be displayed rather than executed.

That's my 2 cents. Btw, if you cannot change the default save option, you can always create a macro with say Keyboard Maestro, and bind it to keyboard shortcut CMD+S. This way, the default save operation will be overridden by your custom sequence of actions that changes the file type.

  • On 10.6.8 they are both treated the same by Finder, see edit. You keyboard suggestion is interesting though... – Vic Sep 25 '14 at 20:12
  • Got it. I've never seen .applescript before. I also thought of a way to do it free. Use BetterTouchTool, create shortcut CMD+S that launches an applescript. The script will keystroke s {command down} and then select the correct dropdown menu before returning the cursor to filename box, type in .applescript and CMD+A. I guess you can use an Automator Service, but I don't know if it will override the existing CMD+S. BTT definitely will. – fartheraway Sep 25 '14 at 20:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.