I remember at one time being excited to find a "Create Font Sample" script -- it's in the AppleScript menu, under Font Book » Create Font Sample. I remember being disapointed to find out that it only worked on certain fonts. The only way I would be able to make it work would be to add all the fonts to the script.
Today I wished I had a sample of the couple thousand fonts I have on my system, so I decided to look at the "Create Font Sample" script again. Much to my delight, I found that, at some point, Apple fixed this potentially handy script and it now works. I don't know when they fixed it, but I'm glad they did.
[robg adds: I found that, on my machine at least, this script only samples the selected font families in Font Book. The first time I ran it, it printed exactly one sample font. When I looked at Font Book, that font was selected in the Font column. So I clicked on it (to make sure the Font column was active), then pressed Command-A (to select all), then re-ran the script. The script then created a new TextEdit document with a sample of every font on my machine. So if you don't get the results you expect, check the Font column selection in Font Book.]
Here's a hint ... don't put a mini CD in your MacBook! If you do, like I did, and it gets stuck, like mine did, well ... I managed to get it out by turning my MacBook on its side and shaking it.
[robg adds: Mini CDs (and any other non-standard CD size or shape, for that matter, should never be put into a slot-loading CD/DVD drive on any Mac that is thus equipped. If you have a tray-loading drive, I think the Mini CD format might work, but I haven't tested one myself.]
If you need a quick way to get the full path to a file or folder, save the following Applescript as an application:
on open {dropped_item}
tell application "Finder" to set the clipboard to the ¬
dropped_item as text
end open
Copy and paste the text into Script Editor, then choose File » Save As, and set the File Format pop-up to application. Then whenever you need to get the path to an item, simply drag that item onto your script's application icon, and the path to the dropped item will be placed on the clipboard.
Many people here on MacOSXHints have posted cool undocumented features based on holding down modifier keys, but I've always wanted a compiled list of all of them, because I will occasionally forget a few. So, I compiled the ones on MacOSXHints, and added a lot more that I don't think were here yet. My description, except for a few, assume that you are holding that modifier key as you are following the directions. Some of them aren't very descriptive, so be sure to post a comment if you can't understand any of them, or if they don't work for you. Additionally, be sure to add more comments of additional tricks that I have not mentioned.
To make it easier, I have posted it here in the remainder of this hint, and on a wiki so that it is easier to collaborate and make the list bigger. Read on to see my list...
[robg adds: I haven't verified all of these, nor am I sure which appear here elsewhere ... but shortcuts are always of interest, so I felt it worth posting.]
I have a Mac mini in the bedroom which we use for watching movies and controlling the music throughout the apartment. During the day, I want it to show a screensaver (a Flickr slideshow using ShuffleSaver) for a while before blanking the screen. But at night, I want it to go dark quickly so it doesn't keep us up.
I put this in root's crontab to do it automatically:
[robg adds: The easiest way to set root's crontab, if you're not an experienced command line user, is to use Cronnix. We have twoother hints dealing with changing the display sleep times.]
If you save the following AppleScript into /Library » Scripts » Folder Action Scripts, and set it up as a folder action, it will automatically color-label any file that you drop into the folder. I use it on my desktop to automatically color code anything that I download. Here's how to use it:
Copy this code snippet into Script Editor:
on adding folder items to this_folder after receiving these_items
set fileColorList to {oranges:{"mpg", "mpeg", "bmp", "wma", "c", "cpp", "dmg", "doc"}, reds:{"asf", "jpg", "jpeg", "ram", "h", "hpp", "mpkg", "iso", "bin", "ppt", "pps"}, yellows:{"mov", "qt", "gif", "aif", "aiff", "htm", "html", "hqx", "tar", "xls"}, greens:{"mp4", "rgb", "rgba", "pcm", "js", "css", "cgi", "pkg", "gz", "z", "tgz", "pdf"}, blues:{"avi", "tif", "tiff", "mp3", "m", "zip", "eps", "ai"}, purples:{"wmv", "png", "wav", "scpt", "tbz", "bz2", "dat", "txt", "prefs"}, greys:{"rm", "ram", "ra", "psd", "pl", "xml", "plist", "sit", "rar", "rtf", "rtfd", "torrent"}}
tell application "Finder"
repeat with myFile in these_items
--display dialog myFile as string
if the name extension of myFile is in oranges of fileColorList then
set label index of myFile to 1
else if the name extension of myFile is in reds of fileColorList then
set label index of myFile to 2
else if the name extension of myFile is in yellows of fileColorList then
set label index of myFile to 3
else if the name extension of myFile is in blues of fileColorList then
set label index of myFile to 4
else if the name extension of myFile is in purples of fileColorList then
set label index of myFile to 5
else if the name extension of myFile is in greens of fileColorList then
set label index of myFile to 6
else if the name extension of myFile is in greys of fileColorList then
set label index of myFile to 7
end if
end repeat
end tell
end adding folder items to
Save the script into /Library » Scripts » Folder Action Scripts.
Control-click on the Desktop and select Enable Folder Actions from the pop-up menu.
Control-click on the desktop and select Configure Folder Actions from the pop-up menu.
Select the script that you just saved from the list.
Voila -- anything you move or download onto the desktop will automatically get a color label (as long as the extensions are in the script). Feel free to customize the color assignments, and add as many extensions to the colors in the script as you'd like.
Once iTunes downloads track info for a store-bought audio CD, OS X pretends that it is the real directory info for the disc. To make a true duplicate of the CD at this point (i.e. with the proper generic file names), you have to hide the CDDB info, as follows:
Eject the CD (if inserted)
Open iTunes Preferences
Click on Advanced, and then Importing
Uncheck "Automatically retrieve CD track names from Internet"
Quit iTunes
In your home folder, open Library » Preferences
Rename "CD Info.cidb" to "CD Info.cidb.bak" or similar
Re-insert the CD
The CD will now show up with the true track names, and iTunes will not go online to replace them. Do whatever you need with the CD in this state. When done, quit iTunes if it has opened, then rename the CD Info.cidb file back to its original name.
Note that until you restore the CD Info.cidb file, all CDs that you insert will show up with generic track names. Also remember to switch your iTunes importing preferences back to normal.
I've been playing around trying to optimise my system temperature on a dual G4 that runs all the time. I've installed Apple's CHUD version 3.5.2 (FTP site for CHUD tools) to access Nap mode -- I don't think newer versions support Nap mode.
Apart from anything, though, I hate the noise the machine makes with nap mode on -- there's a noticeable change in frequency as the CPU enters and exits Nap mode. So I wrote an AppleScript (adapted from the script in this hint) to set nap mode and single processor options to reduce power consumption when the machine's not in use, and restore them when you come back. Comment out the cpu_count line if you're on a single processor machine.
Save the file as an application, with Startup Window unchecked (it took me a while to figure that one out), and add it to your login items -- then you're all set.
I've got this new Mac mini, and I wanted to clone my old hard disk onto the new mac mini -- noe that this only works with same processor type in both machines. Of course, the first thing that pops into my mind is using Carbon Copy Cloner or SuperDuper or rsync or even ditto followed by some blessing. But wait ... I hooked up the old Mac in Target Disk Mode (start it up with the 'T' key held down) with a FireWire cable to the second Mac mini.
So I insert the MacOS X 10.4 install disk, boot from it, select Disk Utility from the Start menu, and choose the volume of the new Mac. I use the Restore tab, drag and drop the old drive as the source, and the new one as the target, and press the button. Et voila! After copying, I can boot the new Mac with an exact clone of the old one. This seems obvious, but I haven't seen it mentioned here before.
[robg adds: This technique may result in some issues if the machines aren't nearly identical -- as a matter of practice, I never clone an old machine's startup drive to a new machine, given that I don't know exactly what changes have been made on the new machine. But if you're setting up a number of identical machines, this could be one way of speeding the process.]
I have always wanted to have the ability to remove files from the trash which were deleted a long time ago. I have just written an AppleScript which renames files and/or folders after they have been put into the Trash to help with this task. Date and time are added to the original filename. So for example, if the file XYZ.txt has been deleted, then the script renames it to _@_YYYYMMDD-HHMMSS_XYZ.txt. This gives me the possibility to sort those files and folder by date and time.
I had to put an identification string (_@_) at the beginning because the Repeat loop takes the newly renamed files into account, which produces a never-ending loop. Maybe somebody can find a better solution.
I used Folder Actions (implemented on OS X 10.3 and newer) on the Trash folder (~/.Trash) to let this script run as soon as a file or folder has been put inside. Copy/paste the script into the Script Editor and save it as and Application under the name ToTrash into ~/Library -> Scripts -> Folder Action Scripts to use it in this manner.
To accompany this script, I have written another that then checks the renamed files and deletes those older than a specified age. The number of days (which is presently set to 15) can be changed in the perl part of the script (localtime(time - 15 * 86400);). The path Macintosh HD:Users:user:.Trash: must be customized to match your machine.