Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Run a Time Machine backup then shut down System 10.5
Here's an AppleScript I use to run a Time Machine backup, and then shut down the machine. As is the case with most shut down scripts, I suppose it would be a good idea to quit whatever programs you know of that are open before running the script. [robg adds: I haven't tested this one, beyond making sure it compiled in Script Editor. After pasting into Script Editor, save it as a script then use your favorite method of making it easier to access -- toolbar, sidebar, dock, or hot keys via a third-party app.]
    •  Comments (5)  
  • Currently 2.67 / 5
  You rated: 5 / 5 (9 votes cast)
[20,238 views]  View Printable Version
10.5: Easily create Quick Look viewable log file aliases System 10.5
Here's an easy way to keep an eye on console log files. Launch, then drag any of the log files you'd like to monitor from the sidebar to your desktop. This creates an alias to that log file, which you can then easily access by double-clicking it. For even faster access, though, you can use Quick Look on the alias -- just select it and tap the Space Bar, and up comes a Quick Look window of that log file.

[robg adds: You can only drag files from the Log Files section of the sidebar, not the Log Database Queries section -- these are more like Smart Folders for log files.]
  Post a comment  •  Comments (5)  
  • Currently 2.14 / 5
  You rated: 5 / 5 (7 votes cast)
[6,856 views]  View Printable Version
10.5: Use Time Machine to create a bootable backup System 10.5
In the event of a drive failure, Time Machine has the ability to create a bootable backup. It takes some preparation, however, which must be done before disaster strikes.

Using Disk Utility, create a partition on the drive you are using for Time Machine (see Disk Utility Help for instructions on how to do this without erasing your Time Machine backups). The new partition must be large enough to hold the contents of your computer's drive, plus 10 or 20Gb of elbow room. If your system weighs 85Gb, then the new partition should be 100Gb or so. Leave this partition blank, and go on with your life.

Now, when (not if!) your Mac's drive fails, do the following. Make sure your Time Machine drive is plugged in and powered on, then insert your Mac OS X Install disc and restart your Mac. In the installer, choose Utilities » Restore System from Backup. Click Continue in the resulting dialog, then select your Time Machine volume. Choose the Time Machine backup that you want to restore (probably the most recent).

Then, when you are prompted for a destination volume, choose the empty partition you created on your Time Machine drive. Time Machine will create a bootable duplicate of your system, which you can use until you replace your faulty main drive. When your Mac is healthy again, you can reinstall your system from the backup drive using either Time Machine, or Migration Assistant (from the new bootable volume you created).

Note that this solution hinges on the ability to get an install disk inserted and booted, on your broken Mac. The paranoid obsessive backer-upper will also want to have a (SuperDuper or Carbon Copy) clone of his drive stashed somewhere.
  Post a comment  •  Comments (16)  
  • Currently 2.63 / 5
  You rated: 4 / 5 (8 votes cast)
[28,660 views]  View Printable Version
10.5: Fix Time Machine sparse images with Disk Utility System 10.5
I don't know how long this capability has been available since I didn't need it until today. Disk Utility in OS X 10.5.3 can now repair a networked Sparse image bundle without mounting it.

Locate the sparse image bundle on the networked drive; the image file will be named ComputerName_MAC-address.sparsebundle. Drag the sparsebundle file into the left column of Disk Utility. Now,select it and click Repair Disk on the First Aid tab. Depending on the size of the file, this could take a few hours to repair. This is, however, much nicer than having to remember the command line procedure!
  Post a comment  •  Comments (3)  
  • Currently 2.29 / 5
  You rated: 5 / 5 (7 votes cast)
[18,726 views]  View Printable Version
10.5: Set Help Viewer windows to non-floating mode System 10.5
The following Terminal command will revert the Help Viewer window to its "not always floating" 10.4 behavior:
defaults write NormalWindow -bool true
Additionally, execute the following (bash) commands as an administrator in Terminal to have access to the application via Command-Tab or its Dock icon:
sudo defaults write "${i%.plist}" LSUIElement 0
sudo chmod 644 "$i"
Sources: [robg adds: This hint makes the second half of this previous hint (which required hacking the Help Viewer executable code to change the window behavior) irrelevant. There's still some good info in the previous hint if you'd like to not only gain a dock icon for Help Viewer, but also change the window's behavior (by editing its .nib file). For most people, though, I suspect the simple Terminal command in this hint will be sufficient. I went through the Help Viewer binary files in the 10.5 release, and I honestly don't recall seeing the NormalWindow string anywhere, so this may be new in 10.5.3 (or I just overlooked it with the earlier release).]
  Post a comment  •  Comments (22)  
  • Currently 3.00 / 5
  You rated: 1 / 5 (10 votes cast)
[21,588 views]  View Printable Version
10.5: Move the Help window from one space to another System 10.5
For whatever reason, Apple decided that the Leopard Help window needed to be a floating window. Among other things, this means that you cannot drag it across Spaces. If you switch spaces while you open the Help window and accidentally open it in the wrong space, you may feel that you have to reload the whole thing in the correct space.

The solution is easy, though perhaps not intuitive: minimize the Help window and reopen it in the space you want it in. This should work with any window that can be minimized, even if doesn't transfer spaces by the usual methods.
  Post a comment  •  Comments (7)  
  • Currently 1.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
[10,388 views]  View Printable Version
10.5: A simpler way to open files in the trash System 10.5
This previous hint explains how to use Quick Look to preview files in the trash. But what if you want to actually open the trashed file?

It turns out that's amazing simple -- just double-click on the Quick Look window to open the document itself. Previously, you'd have to either move the file out of the trash, or drag and drop it onto an application icon in the Dock.
  Post a comment  •  Comments (5)  
  • Currently 1.29 / 5
  You rated: 1 / 5 (7 votes cast)
[7,438 views]  View Printable Version
10.5: Organize data files for networked Time Machine use System 10.5
Time Machine is great, and being able to use Time Machine on a network volume is just amazing, but if you don't take care of the way your data are organized, it can quickly become a huge CPU and network bandwidth eater. To understand how, you must understand how Time Machine works. First of all, the first backup backs up everything but some exclusions covered in previous tips -- it's a simple full backup, in other words.

Then comes incremental backups. The main mechanism used to get consistent 'snapshots' of a volume during its life is as follows. Recursively from the root directory, the system checks if a directory changed (files added or deleted), then:
  • If directory changed, then each file is inspected for changes.
    • File changed? If so, copy the new version
    • File not changed? Create a hard link that points to the initial location of the file on disk.
  • If the directory did not change, then create a hard link that points to the initial location of the directory on disk.
This is not a big issue on a local drive, because hard links are really quick to create, but when talking about network access, it can really become a huge bottleneck if there are thousands of hard links to create. That's because while a big file can be relatively quick to copy, creating a large number of little files or hard links is time consuming.

When can this become an issue, and what can you do to help prevent it? Read on for those answers...

read more (411 words)   Post a comment  •  Comments (7)  
  • Currently 1.86 / 5
  You rated: 5 / 5 (7 votes cast)
[10,285 views]  View Printable Version
10.5: Eject stubborn disk images via AppleScript System 10.5
Leopard sometimes can be a little reluctant to eject disks and disk images in the Finder. It doesn't matter if you click the Eject button in the Finder's sidebar, drag the disk to the Trash, or right-click and choose Eject, the Finder just silently ignores you. You can open Disk Utilty though and eject it fine that way (unless there are files open on the image, of course). This AppleScript will eject those troublesome disks:
    Eject Disks © RickoKid 2008
    Version 0.1
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <>.

set prefaceMessage to ""
set confirm to false

-- check if current selection in Finder contains any ejectable disks
set ejectables to my findEjectable(selection of application "Finder")
if (count of ejectables) is greater than 0 then
  -- Ejectable disks are selected in Finder, add them to the eject list
  set ejectList to ejectables
  set prefaceMessage to "Note: Ejecting disks selected in Finder." & return & return
  -- No ejectable disks in Finder selection; look for all ejectable disks on the system ...
    tell application "Finder" to set allEjectables to name of every disk whose ejectable is true
  on error
    -- Finder throws an error (tantrum?) if it can't match the 'whose' condition, ie when there are no disks to match
    display alert "No ejectable disks" message "Couldn't find any ejectable disks on your system!" as informational buttons {"OK"} giving up after 10
    return "Error: No ejectable disks."
  end try
  -- if ejectable disks are found ...
  if (count of allEjectables) is 1 then
    set ejectList to allEjectables
    set confirm to true
  else if (count of allEjectables) is greater than 1 then
    set ejectList to choose from list allEjectables with title "Eject Disk" with prompt "Choose which disk(s) to eject" OK button name "Eject" with multiple selections allowed without empty selection allowed
  end if
end if

my kickoffEject(ejectList, prefaceMessage, confirm)

on open droppedDisks
  set ejectables to findEjectable(droppedDisks)
  my kickoffEject(ejectables, "Note: Ejecting dropped disks." & return & return, false)
end open

on findEjectable(selectedList)
  set ejectables to {}
  tell application "Finder"
    repeat with selectedItem in selectedList
      if class of selectedItem is alias then
        set nameOfItem to name of selectedItem
        set matchingDisks to (every disk whose name is nameOfItem and ejectable is true)
        repeat with matchItem in matchingDisks
          set ejectables to ejectables & {name of matchItem}
        end repeat
      else if class of selectedItem is disk and ejectable of selectedItem then
        set ejectables to ejectables & {name of selectedItem}
      end if
    end repeat
  end tell
  return ejectables
end findEjectable

on kickoffEject(ejectList, preface, confirm)
  set textDelimiters to AppleScript's text item delimiters
  set AppleScript's text item delimiters to return
  -- if disks are chosen (don't try if Cancel is clicked) or 1 is confirmed or disks are selected in Finder
  set messages to {}
  set moreInfo to {}
  if (count of ejectList) is greater than 0 then
    if confirm then
      set ejectIt to display alert "Eject" message "Are you sure you want to eject the following disk(s)?" & return & return & (ejectList as text) as warning buttons {"Cancel", "Eject"} default button "Eject" cancel button "Cancel" giving up after 20
      if button returned of ejectIt is "Cancel" then return "User cancelled."
    end if
    set AppleScript's text item delimiters to return & tab
    repeat with ejectDisk in ejectList
        set ejectResult to (do shell script "touch /tmp/" & ejectDisk & "-report.txt; hdiutil detach '/Volumes/" & ejectDisk & "' &> /tmp/" & ejectDisk & "-report.txt &")
        repeat while ejectResult is equal to ""
          delay 0.5
          set ejectResult to (do shell script "cat  /tmp/" & ejectDisk & "-report.txt")
        end repeat
        do shell script "rm /tmp/" & ejectDisk & "-report.txt"
        if ejectResult contains "error" then error ejectResult
        set messages to messages & {"Ejected disk \"" & ejectDisk & "\" successfully."}
        set moreInfo to moreInfo & {"Success: disk \"" & ejectDisk & "\": " & return & tab & (paragraphs of ejectResult as text)}
      on error errorMsg
        set messages to messages & {"Error: disk \"" & ejectDisk & "\" could not be ejected."}
        set moreInfo to moreInfo & {"Fail: disk \"" & ejectDisk & "\":" & return & tab & errorMsg}
      end try
    end repeat
    set AppleScript's text item delimiters to return
    if (count of messages) is not 0 then
      set report to display alert "Ejection Results" message preface & (messages as text) as informational buttons {"More info ...", "Close"} default button "Close" giving up after 60
      if button returned of report is "More info ..." then
        set moreDetailedInfo to {}
        repeat with eachMessage in moreInfo
          if eachMessage contains "error" then
            set diskDev to do shell script "mount | grep " & word 3 of eachMessage & " |awk '{print $1}'"
            set openFiles to paragraphs of (do shell script "lsof -Fc " & diskDev & " |  sed -ne '/c/ s/c//p'")
            if (count of openFiles) is greater than 0 then
              set AppleScript's text item delimiters to return & tab & tab
              set eachMessage to eachMessage & return & tab & "Processes open on disk:" & return & tab & tab & (openFiles as text)
              set AppleScript's text item delimiters to return
            end if
          end if
          set moreDetailedInfo to moreDetailedInfo & {return & eachMessage}
        end repeat
        display alert "Ejection Details" message (moreDetailedInfo as text) as informational buttons {"OK"} default button "OK"
      end if
    end if
  end if
  set AppleScript's text item delimiters to textDelimiters
end kickoffEject
The script will let you eject troublesome disks quickly if the Finder is ignoring your requests. It will also tell you which applications are stopping the disk from being ejected, as opposed to the Finder's generic "something is open on that disk, but I'm not telling you what!" You can find a ready-to-run version of the script in this post on my site.

[robg adds: When you run the AppleScript, a list of mounted disks will appear, including FireWire drives, CD/DVDs, and disk images. Select the one you'd like to eject then click the Eject button. I didn't have any 'stuck' devices to test this with, but it worked fine on my three test runs with a FireWire disk, a CD, and a disk image.]
  Post a comment  •  Comments (16)  
  • Currently 2.00 / 5
  You rated: 4 / 5 (8 votes cast)
[20,822 views]  View Printable Version
10.5: Switch search locations via keyboard shortcut System 10.5
I discovered this tonight. If you initiate a search in the Finder (Command-F) from a folder (other than your user's home folder), the Search criteria shows This Mac and the name of the current directory as search locations. If you press Command-F again, the current directory choice is replaced with your user's Home folder.
  Post a comment  •  Comments (12)  
  • Currently 2.50 / 5
  You rated: 3 / 5 (6 votes cast)
[7,012 views]  View Printable Version