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

Flatten a folder's structure via AppleScript Desktop
The following AppleScript traverses the currently-selected folder in the Finder, moves the contents of all subfolders of that folder up to the top level, then moves the (now empty) subfolders to the trash. [robg adds: Copy and paste the above into Script Editor, then switch to the Finder, select a folder, switch back to Script Editor, and press Run. Because this script is non-reversible, I strongly recommend first using it on a non-critical test folder -- a duplicate of the folder you intend to flatten, for instance. That's how I tested it, and it worked as described (at least in 10.5; I don't know if it will run in 10.4). If this is something you do often, you could save the script to your user's Library » Scripts » Applications » Finder folder, where it'd be available from the Scripts entry in the menu bar.]
  Post a comment  •  Comments (20)  
  • Currently 2.10 / 5
  You rated: 1 / 5 (10 votes cast)
 
[10,948 views] Email Article To a Friend View Printable Version
Set desktop pictures using AppleScript Desktop
This hint was inspired by a study that found red wallpaper conducive to detail-oriented work, while blue wallpaper works better for creative work. Based on that, I wrote a simple AppleScript to display a dialog that allows the user to choose between working environments. The script then sets the desktop picture based on the user's selection.

Note that this hint assumes you've already created the new solid colors (very dark gray, very dark blue, and very dark red) as explained in this previous hint. Once you have those colors (or others, if you prefer; just change the script as necessary), create the following AppleScript: [robg adds: I tested this, and it works as described. If you want to use more colors, you need to change both the buttonList and colorList lines so that they remain in sync. The list of colors in colorList must exactly match the colors' filenames as seen in the Finder.]
  Post a comment  •  Comments (8)  
  • Currently 1.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[13,048 views] Email Article To a Friend View Printable Version
Sort files into subfolders based on date added Desktop
There are many published methods to put files in named folders based on date created or modified, but this one puts them in corresponding folders based on the date the file was added to the folder, similar to the sorting option for stacks in the Dock -- I use this to organize my Downloads folder.

The following AppleScript works by exploiting the HFS+ inode table, and retrieves the date which the file's name was added to the directory tree, regardless of when it was previously modified or created in other locations.
tell application "Finder"
    set mifold to choose folder
    set filelist to every file of mifold as list
    set foldlist to every folder of mifold as list
    repeat with i from 1 to number of items in filelist
        set subj to item i of filelist as alias
        set epoch to (do shell script "stat -f \"%B\" " & (quoted form of (POSIX path of subj)))
        set caldate to do shell script ("date -r " & epoch & " \"+%Y-%m-%d\"")
        
        if not (exists folder caldate of mifold) then
            make new folder at mifold with properties {name:caldate}
        end if
        try
            (* try ignores errors from locked files *)
            move file subj to folder caldate of mifold
        end try
    end repeat
    repeat with j from 1 to number of items in foldlist
        set subj to item j of foldlist as alias
        if name of subj does not start with "200" then
            set epoch to (do shell script "stat -f \"%B\" " & (quoted form of (POSIX path of subj)))
            set caldate to do shell script ("date -r " & epoch & " \"+%Y-%m-%d\"")
            if not (exists folder caldate of mifold) then
                make new folder at mifold with properties {name:caldate}
            end if
            try
                (* try ignores errors from locked items *)
                move folder subj to folder caldate of mifold
            end try
            
        end if
    end repeat
end tell
It could probably use some optimization, so feel free to make suggestions if you're an AppleScript geek!

[robg adds: This works as described, at least on the folders I tested it with. Note there's no going back, of course, so if you run the script, you'd have to manually restore the flat folder structure if you change your mind. A couple of other hints in this category include organizing the Downloads folder by download date (which changes the files' modifications times to re-sort them) and using Hazel to sort items in folders (among its other features).]
  Post a comment  •  Comments (3)  
  • Currently 1.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[12,645 views] Email Article To a Friend View Printable Version
10.5: Change folder sort order in the Finder's Kind view Desktop
Note: This hint was lost when the site was hacked on April 23rd. I've reposted it, and the comment thread, as best as I could. --robg

In the Finder's list view, if you sort by Kind, folders are lumped together in the middle of the list. If you'd rather see all the folders at the beginning of the list, here's how to change the sort order. In the Finder, navigate to /System » Library » CoreServices » Finder.app » Contents » Resources » English.lproj (or the folder for your language). In that folder, open the InfoPlist.strings file in a pure text editor. Inside the file, find this section and entry:
/* General kind strings */
"Folder" = "Folder";
Leave the first line alone, but change the second to read:
"Folder" = " Folder";
Note that I have added only a single space before Folder. Save the file after making the change, and then restart OS X. To test your change, open a Finder window and view by Kind (either via View » Show View Options, or by pressing Command-2, then clicking on the Kind column header).

robg cautions: As noted in the comments, this hint will break OS X 10.5's code signing for the Finder. In theory, this will have some bad consequences, as you'll no longer be able to access the keychain when using the Finder. Proceed at your own risk; if you undo the edit, at least based on my testing, things will return to normal (code signing checks will pass).

[robg adds: This is an update to this much older hint, which required modifying a system-wide framework. Note that restarting isn't required; just restart the Finder via Terminal, Activity Monitor, or Option-click-and-hold its Dock icon.

If you want folders at the end of the list, instead of the beginning, you'll have to use one of a few special characters:
  • µ (mu): Option-M
  • π (pi): Option-P
  • Ω (omega): Option-Z
  •  (Apple): Shift-Option-K
I also did a bit of experimenting with the Edit » Special Characters palette. Most any Greek letter (European Scripts » Greek in the All Character view) will force a name to the end of the list, as will some Cyrillic characters. But that's about it; pretty much everything else I tested forced the names to the front of the list.]
  Post a comment  •  Comments (15)  
  • Currently 2.14 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[21,927 views] Email Article To a Friend View Printable Version
10.5: Retain positions when moving windows in Spaces Desktop
Today I noticed that you can force Spaces to move windows to another Space while retaining their relative position on the screen. To do so, open the Spaces overview (F8 by default), and hold the Command key while dragging a window to another Space.

I found this by accident and don't think it's that useful, but perhaps you will...

[robg adds: This was mentioned in a comment to this hint, but I thought it worth sharing as a real hint. In testing it, the behavior varies between programs with one window (iCal) and those with many windows (iChat, Safari, whatever). If a program has but one window, then Command (or Shift or Control) will move it while retaining its location. If a program has multiple windows, any of those keys will move all of that program's windows while retaining their positions. I couldn't, in fact, find a way to move all windows of a program to another Space without retaining their positions -- I had to manually move them within the new Space (again, while holding any of those keys so that all windows moved) to change their position.]
  Post a comment  •  Comments (11)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[8,178 views] Email Article To a Friend View Printable Version
Move selected items into ready-to-rename folder Desktop
This is a simple AppleScript for the Finder which moves the currently selected items into a newly-created folder, and puts the new folder into rename mode. I use this to quickly sort my files into properly-named folders.
(*
Move items into new folder
Author: Barry Els
Version: 1.1
*)

tell application "Finder"
  try
    
    set theSelection to selection
    
    set currentPath to ((the first item of the theSelection) as alias)
    set parentPath to currentPath
    
    if (currentPath as string) ends with ":" then -- it is a folder
      set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
      set the parentPath to (text items 1 thru -3 of (currentPath as string)) as string
      set AppleScript's text item delimiters to od
    else -- it is a file
      set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
      set the parentPath to (text items 1 thru -2 of (currentPath as string)) as string
      set AppleScript's text item delimiters to od
    end if
    
    try
      
      set newFolder to (my createFolder(parentPath))
      move theSelection to newFolder
      
      delay 0.1
      set selection to newFolder
      tell application "System Events"
        keystroke return
        quit
      end tell
      
    end try
    
  on error
    (*
    no folder or file is selected, warn the user
    *)
    
    display dialog ("Please select one or several items to group" & (theSelection as string))
    
  end try
  
end tell

on createFolder(selectedPath)
  tell application "Finder"
    set createdFolder to make new folder at selectedPath
  end tell
  
  return createdFolder
end createFolder
After saving the script, you'll want to use a keyboard shortcut tool (I use Spark) to run this script via the keyboard -- I've set the key combo for this one to Command-G.

[robg adds: This worked as described in my testing.]
  Post a comment  •  Comments (19)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[9,605 views] Email Article To a Friend View Printable Version
10.5: Put Smart Folders under Places on the Sidebar Desktop
If you are like me, you have a lot of entries in the Places section of the sidebar in Leopard's Finder. What if you want a Smart Folder that aggregates your favorite/recent places (or provides any Smart Folder functionality), but you don't want to have to scroll down to the Search For section of the sidebar? In other words, you'd like to place your Smart Folders in the Places section of the sidebar.

By default, Apple disables moving Smart Folders to the Places category of the sidebar. So how do you get around this? Easily.

Take any saved search on the sidebar, Control-click on it and select Open Enclosing Folder from the pop-up menu. Then select your search and choose File » Make Alias, and drag the alias to your sidebar. Done!

[robg adds: I think this can be further simplified -- once the enclosing folder is visible, you can drag any of the visible Smart Folders directly to the Places section of the sidebar; no alias is required (at least not on my 10.5.6 machine it's not).]
  Post a comment  •  Comments (6)  
  • Currently 2.38 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (8 votes cast)
 
[12,288 views] Email Article To a Friend View Printable Version
10.5: Create a simple contact sheet Desktop
It's trivial, but convenient: create a quick and dirty 'contact sheet' of images using Quick Look, three simple keyboard shortcuts, and one mouse-click:
  1. Open the folder containing the set of image files.
  2. Press Command-A, Command-Option-Y, click the Index Sheet button, then press Command-Shift-3.
Just that easily, and you've made a contact sheet from the Quick Look display -- you'll find it on your Desktop, in a file named Picture 1. With a very little bit of coding, you can turn this into a simple script, too.
  Post a comment  •  Comments (5)  
  • Currently 1.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[16,374 views] Email Article To a Friend View Printable Version
Automatically clean up Finder's Recent Folders menu Desktop
Some of you might be using the hidden setting to control the number of entries in the Recent Items menus (as in this hint or via TinkerTool) to disable the menus entirely, for example on shared computers or other situations.

Unfortunately, the Finder has a menu of recently-accessed folders in the Go menu that nobody has yet found a way to disable. In case you really need to get rid of this feature, here is a crontab line that will clear the menu every minute:
* * * * * osascript -e 'tell application "System Events" to click menu item "Clear Menu" of menu of menu item "Recent Folders" of menu of menu bar item "Go" of menu bar of process "Finder"' >&/dev/null
It works by clicking on Finder's Recent Folders » Clear Menu menu item every minute. The nice thing is that it does so in an invisible manner, without bringing Finder to the front or otherwise disrupting your workflow, and it wastes only a few milliseconds of processor time every minute. This is a generic technique that may be applied to all sorts of needs: just look at the string of menu labels, and adapt to your needs.

You will need to enable access for assistive devices in the Universal Access System Preferences panel for this to work.

[robg adds: If you need help with crontab, this older hint provides a decent starting point.]
  Post a comment  •  Comments (7)  
  • Currently 1.43 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[15,957 views] Email Article To a Friend View Printable Version
Create an iPhoto-like folder view in the Finder Desktop
To create an iPhoto-like size-adjustable icon view of a folder, just put "" (with nothing inside the quotes) in the search box in a Finder window. Set it to the folder of interest, and to search by name, and choose icon view.

Now you can see a view with the zoom scroller on the bottom right. Very useful to see images or videos on folders.

[robg adds: This is a variation on this older hint, which used a smart folder to display a narrow range of results with the slider; this method just opens it up to all files within a folder. Alternatively, as noted in the original hint, you could just opt to leave the View Options window open instead, as it contains a slider for icon size (as well as grid spacing).]
  Post a comment  •  Comments (4)  
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[8,096 views] Email Article To a Friend View Printable Version