Tag Archive: “applescript”
FastScripts as Apple Menu
Back in the day, the System Folder contained an Apple Menu Items folder, the contents of which appeared in the Apple menu. Choosing an item from the menu opened the item from the folder. It was easy to customize the Apple menu by adding folders and aliases to the Apple Menu Items folder.
Here’s what it looked like by default in Mac OS 8.5:
In Mac OS X, of course, the Apple menu is no longer customizable. It still contains some useful items, but it’s not quite the familiar place it once was. The Dock has taken its place as a quick way to access favorite files and folders.
So, if you want to access a bunch of applications from a tidy little menu, and you don’t find it useful to throw your whole Applications folder in the Dock, you turn to the world of third party launchers. Here’s an unlikely solution.
FastScripts is a program I recommend for running scripts with keyboard shortcuts. It’s a power user thing. However, a little-advertised fact about FastScripts is that it will open anything in your Scripts folder, not just scripts.
Choose Open Scripts Folder from the FastScripts menu, and put whatever you’d like—including subfolders—in the folder that appears. Now you can launch those files from the FastScripts menu:
The script items in the menu reside in a subfolder of the Scripts/Applications folder. The subfolders are named after specific applications, and appear in the menu only when that application is frontmost.
Posted on Saturday, September 13th, 2008.
Bricksmith Custom Categories
Here is a hack to add new categories to the Bricksmith part browser. The part catalog is normally organized into categories based on the type of each part (such as brick, plate, or tile). However, if you’re building a model based on a real set, it’s just as useful to present the parts from that set in one category.
Adding a category from a Peeron inventory
To create a category consisting of the parts from set 4891, enter 4891 and click Peeron Inventory:
The script will retrieve the corresponding list of parts and populate a new category containing them:
Adding a category from a file
To create a category based on an arbitrary group of parts, save a list of part file names, like this:
3005.dat
3004.dat
3003.dat
3001.dat
Then enter a name for your category and click From File. You’ll be prompted to select the list you just created.
The script will add the listed parts to the named category:
Limitations
The script is awfully slow. AppleScript’s property list commands are not well suited for making many changes.
Parts listed in the file or inventory which are not already present in your part library will not be included in the category.
New categories are not visible until you restart Bricksmith. (I recommend quitting Bricksmith before running the script anyway.) Custom categories are lost when you reload the part list from Bricksmith’s Parts preferences.
No feedback is provided while the script is running.
Errors are not handled particularly well.
Mac OS X 10.5 is required.
It’s really slow.
Download
Bricksmith Catalog Custom Categories 26.4 KB
Posted on Saturday, June 21st, 2008.
Note Poster
Here’s a script to create a new post in MarsEdit from a note selected in Yojimbo. Why use a script when it’s already as easy as copy and paste? Well, maybe your computer is running out of paste.
tell application "Yojimbo" set _items to selected items of browser window 1 if (_items is {}) or (_items is missing value) then return set _note to item 1 of _items if class of _note is not note item then return end tell tell application "MarsEdit" set _post to make new document set body of _post to contents of contents of _note set title of _post to name of _note activate end tell
Click here to open the script directly in Script Editor. Save it in ~/Library/Scripts/Applications/Yojimbo
and you’re ready to run.
Posted on Sunday, May 11th, 2008.
Toggling Line Numbers and Soft Wrap in TextWrangler
As with most text editors, TextWrangler provides many options that allow you to customize the editing interface. Two settings I sometimes change are accessible only as preference options or as toolbar menu items. As I would prefer to toggle these features with a single keystroke, I wrote a pair of scripts to do the job. Two associated keyboard shortcuts later, there’s no need to display the toolbar or visit the preferences.
Toggle Line Numbers
This script toggles the show line numbers
property of the frontmost text window.
Toggle Soft Wrap
This script toggles the soft wrap text
property of the frontmost text window.
Download
- Toggle Line Numbers 1.3 KB
- Toggle Soft Wrap 1.3 KB
The color scheme seen in the screenshots is Gruber Dark.
Installation
Unzip the scripts and put them in ~/Library/Application Support/TextWrangler/Scripts
. Keyboard shortcuts can be assigned with the Set Key
button in the Scripts
palette, found under Palettes
in the Window
menu.
Posted on Monday, April 28th, 2008.
Bookmark in Yojimbo for Camino
I’ve posted a Camino-compatible version of my venerable Bookmark in Yojimbo script.
Update: Revised for Camino 1.6. New in Camino 1.6 is the ability to add any script in ~/Library/Scripts/Applications/Camino
to the toolbar, so you don’t even need to use a separate script runner.
Posted on Tuesday, March 4th, 2008.
Yojimbo Tag Companions
I use this little script when I want to ensure that every Yojimbo item with a certain tag also has some other tags. For instance, to ensure that every leoben
item is also tagged cylon
, I run the script, select leoben
from the first list of tags that appears, and cylon
from the second list.
Posted on Thursday, January 17th, 2008.
Select Grep
Update: Now located at https://github.com/anoved/Finder-Scripts/tree/master/Select%20Grep
This script for the Finder is derived directly from the venerable lselect. Rather than select files whose names match a certain pattern, Select Grep selects files whose contents match a certain pattern.
Subdirectories are not searched and the pattern is not case sensitive. Extended regular expressions are supported. Compatibility with binary files has not been tested. The specific options given to grep
are -liE
. The script is easily edited to use different option combinations; please share any improvements.
Put the script in ~/Library/Scripts/Applications/Finder
and run it to select files in the frontmost Finder window that contain the search pattern.
Posted on Saturday, December 8th, 2007.
iTunes Library Item Transfer
My laptop has a 60 GB hard drive. I have a 500 GB external drive which houses my iTunes library and other media. I like to keep some iTunes content on my laptop, but using the Finder or the “Add to Library” file browser to move particular things between libraries gets tedious.
So, I wrote a script that makes it a little simpler. Now I can use iTunes itself to select the items to transfer instead of browsing for the actual files to pull into the target library. Might not sound like a big difference, but it seems like less fuss to me.
Here’s how it works.
Download the script (5k) and put it in ~/Library/Scripts/Applications/iTunes
.
Select some items in iTunes and run the script. iTunes will quit and you will be prompted to reopen it with a different library:
Hold down the Option key as iTunes starts up to select a different library. If you’re transferring files to a new library for the first time, you could even create the new library at this point.
Once you have finished choosing a library, return to the prompt and click Transfer. The items you previously selected will be transferred to the current library and shown in a new “Transfer” playlist labeled with the current date and time.
Tested with Mac OS X 10.4.11 and iTunes 7.5 with the “Copy files to iTunes Music folder when adding to library” option enabled under Advanced→General preferences.
I reckon this could be done with iPhoto, too.
Posted on Thursday, November 15th, 2007.
Lselect Toolbar Icon
Henrik Nyh has created a great Leopard-themed toolbar icon for lselect. Read his post for more information about using lselect and other useful scripts as Finder toolbar buttons with custom icons.
For your convenience, I’ve prepared a copy of the script as a tiny application ready to drag to your toolbar:
Download lselect toolbar app 15k
This is a fine time to mention that lselect really is quite useful! Use it to quickly select all the files in a folder that match a simple pattern.
Posted on Tuesday, November 6th, 2007.
Resize Pages Graphics by Percent
Conspicuously missing from Pages is the ability to resize graphic objects by specific percents. You can say “make this graphic 2 inches wide,” but you can’t say “make this graphic 30% of its current width.” So, I wrote a script to do the dirty work for me:
It resizes the selected graphics by the specified percentage.
Download
The “Recenter” version keeps the graphic centered at its original location, which I have found to be rather annoying. Install in ~/Library/Scripts/Applications/Pages/
and invoke with a script runner of your choice.
Notes
Unfortunately, there doesn’t seem to be a scriptable way to determine whether the “Constrain proportions” options is set for a particular graphic. Since this option affects size changes, I simply make the assumption that it is set. It is, by default, for inserted images. For other graphics, check the “Metrics” inspector pane:
Note that images are not necessarily inserted at their original size. If you want to resize an image to some percentage of its actual size, be sure to click the “Original Size” button before resizing.
This script was written with Pages’ page layout mode in mind, but it should work with graphics in word processing mode, too. There are some rough edges, particularly where handling different sorts of selections is concerned.
Here is a video demonstration.
Posted on Monday, September 24th, 2007.