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

Create Windows-compatible zip files via AppleScript Desktop
While I love working on a Mac, I really hate the fact that you don't have an option to remove Mac-specific files from the zip file created by Finder's Create Archive. I often find myself creating an archive on the Mac only to have to open it with WinZip on the PC so I can take out the hidden dot files (e.g .DS_Store).

So I hacked up this code for the small little archives I create for my website. The code isn't perfect, but I'm sure someone can clean it up and put in some better error trapping.
-- Script name: WinZipMe
-- zip command options: -r = recursive,
--                      -j = junk path (similar to Create Archive)

tell application "Finder"
  -- Note: There's no extensive error trapping on this script
  -- (e.g. folder counts for larger folders to show warnings)
  -- You could also take off any .xxx suffix before adding
  -- the file to the .zip if needed
  set theItem to selection as alias
  set itemPath to quoted form of POSIX path of theItem
  set fileName to name of theItem
  set theFolder to POSIX path of (container of theItem as alias)
  set zipFile to quoted form of (theFolder & fileName & ".zip")
  do shell script "zip -r -j " & zipFile & " " & itemPath
  -- delay 1 -- this may be needed (and adjusted) for larger folders?
  try -- We don't need to say anything if there are no .DS_Store files
    do shell script "zip -d " & zipFile & " '*.DS_Store'"
  end try
end tell
Wouldn't it be great if holding down the Option key while choosing Create Archive would exclude the special hidden Mac dot files?

[robg adds: If you're running 10.4, you can make this script a Finder plug-in using Automator; then it's just a control-click away with any file or folder selected. Open Automator, click on the Automator Library item, then drag the Run AppleScript action to the work area. Replace the (* Your script goes here *) line with the script above, and use File: Save as Plug-in to create a Finder plug-in (I called mine WinZipper). Select anything in the Finder, control-click, and then choose WinZipper from the Automator sub-menu.]
  Post a comment  •  Comments (21)  
  • Currently 2.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[29,135 views] Email Article To a Friend View Printable Version
A script to update a hard drive's free space value Desktop
I found out something annoying about the hard drive icon on the desktop: if you have the Show Item Info option enabled (in View -> Show View Options), then the amount of free space in the info line never gets updated by itself. You either have to quit the Finder, reboot, or log off and on to make it refresh).

I read in some internet forum that copying any file to the top level of the drive (/) would make the available space figure refresh. So what I did was create an empty file in my Documents folder (touch space.txt in the Terminal), and then using crontab and a small script, copy this file every five minutes to /.

Here is the script, which I named freespace_updater.sh:
#!/bin/sh
rm /space.txt
cp /Users/martin/Documents/space.txt /
And the associated crontab entry:
martin$ crontab -l
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/freespace_updater.sh
I know this is very dirty, but at least it refreshes my free space info every five minutes.

[robg adds: I tested this, and was surprised to find that it's true -- if you have hard drives visible on the desktop, and use the Show Item Info option, the free space value never seems to update. But copying and deleting a file from the root level forced an instant update. I would switch the order of commands in the script (cp first, then rm), since that way, nothing is left at the top level, and it seemed to work just as well when I was testing it. What didn't work, somewhat oddly, was touching a file at the top level; it seems an actual copy operation is required to force the update.

If you have multiple volumes, you'd probably need the script to copy a dummy file to the top level of each of them.]
  Post a comment  •  Comments (11)  
  • Currently 3.50 / 5
  You rated: 5 / 5 (4 votes cast)
 
[8,837 views] Email Article To a Friend View Printable Version
Double-click X11 applications to open via the Finder Desktop
I'm afraid to submit this hint for fear everyone in the world knows this except for me ... in 10.4, without X11.app launched and without any Terminal open, you can navigate in the Finder to, for example, /usr/X11R6/bin and double-click on a binary icon like xclock or xterm or xeye or xcalc etc., and it will simply launch -- cleanly, without starting a Terminal session or anything.

For years, I have either launched everything from the command line, or made application wrappers with Platypus or AppleScript, and I was stunned to see that 10.4 (which I have used since it became available) offers this feature. The only shortcoming is that it doesn't seem to permit drag and drop, but perhaps there is even a trick to getting that to work.

[robg adds: I also wasn't aware that X apps could be launched via a Finder double-click; I've been launching them from X11's Terminal every since I started playing around with X11...]
  Post a comment  •  Comments (10)  
  • Currently 2.00 / 5
  You rated: 2 / 5 (4 votes cast)
 
[11,585 views] Email Article To a Friend View Printable Version
Remove a running application from the Dock and switcher Desktop
Warning / Disclaimer:
This trick relies on what is probably a bug to work, and may cause problems depending on what target applications are doing at the time method is applied. The system will even provide a warning to that effect when you try to implement this hint. Proceed at your own risk...

If you have ever been in a situation where you had an application running which you did not wish to continually have to "Tab" past in the ⌘-tab application switcher, it can be removed by simply renaming it while it is running, then restarting the Dock (see below for more on how to do that). The final (important) step is to immediately change the program's name back to what it originally was.

The program will no longer appear in the application switcher nor the Dock. If the application is a permanent item in the Dock, its icon will remain, but the triangle indicating active applications will be absent. Clicking the Docked application's icon will activate the app normally, but the contextual menu will be empty. Interestingly, windows belonging to the application still appear in Exposť.

Notes:
  • The Dock can be restarted using Activity Monitor (in /Applications/Utilities), AppleScript (tell application "Dock" to quit), or various commands using Terminal (also in Utilities; killall Dock).
  • For obvious reasons, it will require Admin access to use this on programs in the global Applications folder, although I suppose a user could, in many cases, run and work on copies.
  • To be more conservative, it may help to kill -STOP the process for the interval that the application's name is altered (ie. kill -STOP pid and kill -CONT pid to resume, where pid is the process ID of the program being skipped)
  • The Finder seems to be immune to the effects of this trick.
[robg adds: Bravely, I tested this one (using a non-critical app) on both 10.3.9 and 10.4.2, and it works. As noted in the warning above, though, it's potentially dangerous and not something I would recommend doing (unless you're willing to take the kill -STOP step as well).]
  Post a comment  •  Comments (9)  
  • Currently 1.00 / 5
  You rated: 1 / 5 (2 votes cast)
 
[15,133 views] Email Article To a Friend View Printable Version
10.4: Use Automator to view any file in a text editor Desktop
Tiger only hintIf you download a text file from the internet, like a ReadMe or a .nfo file, it usually doesn't open in TextEdit unless you explicitly tell the Finder to do so for each and every file you download. You can use the 'Open With' contextual menu, of course, but this menu usually includes a lot of options for generic text files -- so it takes a while to display, and then to scroll through to find TextEdit. You can also, of course, help the Finder learn about each type of generic text file you may download (by using Get Info and changing the default application), but this can be tedious and you may not actually wish to change the default application.

The solution is to create a simple Automator action to open the currently selected file(s) in TextEdit, and install it as a Finder plug-in:
  1. Launch Automator and click on Finder in the Library column.
  2. In the Action column, drag Open Finder Items to the empty area on the right-hand side.
  3. In the Action itself, click the Open with pop-up and set it to TextEdit (or the text editor of your choice).
  4. Select File: Save as Plug-in.
  5. In the dialog that appears, enter the name you want to give to the plugin (eg. View in TextEdit) in the 'Save Plug-in As' field, and set the 'Plug-in for' pop-up to Finder.
  6. Click the Save button.
From now on, you can select any file or files you want to view, control-click on one of them, and select the option View in TextEdit (or whatever name you used) from the Automator sub-menu. This is much quicker than using the Finder's huge Open With menu.

Note: This hint was originally submitted by an anonymous contributor, with a link to a downloadable action. However, the link was broken, and there was no contact information included with the submission, so I couldn't contact the author. I thought the concept sounded useful, however, so I played with Automator for a couple minutes to create my own version of the action. So thanks to the submitter, whomever you were, for the idea to create this simple plug-in.
  Post a comment  •  Comments (10)  
  • Currently 3.25 / 5
  You rated: 3 / 5 (4 votes cast)
 
[13,125 views] Email Article To a Friend View Printable Version
Shorten the Finder's 'Show Item Info' text Desktop
I like having the "Show item info" option enabled in the Finder's view options for the Desktop, but on the 160GB hard drive I have, it often truncates the middle of the text because the area isn't wide enough to show it all. This leads to it being nearly useless and ugly, since the text looks like "152.66 GB, ... .13 GB free." So I decided to see if I could figure out how to change the text.

While I wasn't able to figure out how to completely reformat the text (just showing the free amount would be good enough for me), I did find the string variable for the word "free." It is located in /System -> Library -> CoreServices -> Finder.app -> Contents -> Resources -> English.lproj -> Localizable.strings. Open this file in a Xcode or BBEdit, and find this line "IV9" = "free"; (line 490). Change it to "IV9" = "";, and you just saved an extra four characters. Now all useful information fits into the area provided.

As with all hacks like this, be sure to be careful, make backups, and proceed at your own risk. After you have made the change, just relaunch the Finder using the Force Quit dialog to see the change.
  Post a comment  •  Comments (3)  
  • Currently 2.83 / 5
  You rated: 3 / 5 (6 votes cast)
 
[11,886 views] Email Article To a Friend View Printable Version
10.4: An Automator plug-in to tar and gzip in the Finder Desktop
Tiger only hintI've written an Automator workflow that can be used as a Finder plug-in to tar and gzip any selected files or folders.

First, download the action. After it's downloaded, do this to get it working:
  1. Double click the tgz folder.dmg disk image to mount it.
  2. From your home folder, make the following hierarchy of folders if it doesn't already exist: /Library -> Workflows -> Applications -> Finder
  3. Drag the tgz.workflow workflow from the disk image into the Finder folder you just created.
Now you can select files or folders in the Finder, control- or right-click, go to the Automator sub-menu, and select tgz to compress them.

[robg adds: I've mirrored the action in case the above download link goes away some day. Since 10.4 now retains resource fork info with all the command line utilities, this should be safe to use on any files. I tested it, and was able to compress (and the decompress) a set of files without any troubles. Note that you can also put the workflow in your user's Library folder, following the same structure as above, instead of the top-level Library -- this would install it only for your user instead of all users on the system.]
  Post a comment  •  Comments (21)  
  • Currently 2.80 / 5
  You rated: 2 / 5 (5 votes cast)
 
[19,978 views] Email Article To a Friend View Printable Version
Create a 'parent directory' Toolbar button Desktop
One of the few things I like about Windows that I thought OS X was sorely missing was a Parent Directory button (a button that opens the folder containing the folder the current window is showing). So I created an Applescript application that can be put on the toolbar to do the same thing. Here's the code:
tell application "Finder"
  set fdir to the target of front window as text
  set fname to the name of front window as text
end tell
set AppleScript's text item delimiters to {""}
set x to (length of fname) + 2
set fdir1 to characters 1 thru -2 of fdir as string
if fdir1 is not fname then --is current window at root of hd?
  set up1 to (characters 1 thru -x of fdir) as string
  set AppleScript's text item delimiters to {" "}
  tell application "Finder"
    set target of front window to up1
  end tell
end if
I also zipped the script's source code and the compiled application into a 22KB archive if you want to try them the easy way. This is my first time using AppleScript, so it's probably a bit rough (and it only has the standard AppleScript icon).

[robg adds: There's a built-in "show parent folder" command in the Finder; Go -> Enclosing Folder, or Command-Up Arrow. But as far as I can tell, there's no simple method to get that command into a toolbar button (but I am far from an AppleScript expert). You could use UI scripting to select that menu item, but that seems like more work than the above solution...]
  Post a comment  •  Comments (22)  
  • Currently 3.43 / 5
  You rated: 5 / 5 (7 votes cast)
 
[19,867 views] Email Article To a Friend View Printable Version
Quickly select the desktop from any Finder window Desktop
I found this out when I was trying out Finder shortcut keys. If you have any Finder window selected, and you hit Command-Shift-Up Arrow, it will take the focus off the current window and select the first icon on the desktop, usually the Mac HD icon. A simple little shortcut that might come in useful sometime.

[robg adds: I thought we had this documented here somewhere, but a search seems to show that it's not yet listed. On my 10.4 machine, the first icon on the desktop isn't highlighted automatically; I have to hit Tab to actually highlight the first item.]
  Post a comment  •  Comments (6)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[7,544 views] Email Article To a Friend View Printable Version
Create a screen-locking keyboard shortcut Desktop
I use both an iBook and a Windows-based laptop at work, and it's a must for me to lock the screens on both machines before leaving my desk. I'm a keyboard shortcut junkie, and I quickly became envious of the Ctrl-Alt-Del-Spacebar combo that I could use in Windows XP to swiftly lock the screen (muscle memory is a great thing). So I worked out the following method to enable a keyboard shortcut that locks the screen in OS X -- and no scripting or work in the Terminal is required.
  1. Open the Keychain Access application (/Applications/Utilities/Keychain Access).
  2. Open the Preferences panel (menu: Keychain Access->Preferences).
  3. Make sure "Show Status in Menu Bar" is enabled.
  4. Now close the Preferences panel and then the Keychain Access application.
If you click on the Keychain Access menu extra that should have appeared in the menubar (it looks like a tiny lock), you can try pressing the "Lock Screen" option: this will, as you'd expect, lock the screen.
read more (239 words)   Post a comment  •  Comments (50)  
  • Currently 3.14 / 5
  You rated: 3 / 5 (7 votes cast)
 
[88,546 views] Email Article To a Friend View Printable Version