Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Most document-based Mac OS X applications have a File ---> Open Recent... menu item. This is a list of recent files you've opened with the program. Removing all items is easy; simply select Clear Menu.

However, sometimes you might just want to remove a single item or two rather than everything, such as a file that no longer exists, or one you never want to see again. How do you remove a single item from the Open Recent list, without removing anything else?

Open Recent... example

share|improve this question
1  
Files that do no longer exist are not displayed in all applications that properly implement the Open Recent menu (by not changing the Cocoa default). –  Daniel Beck Jun 6 '11 at 15:42
add comment

2 Answers

up vote 9 down vote accepted

In most applications, application-specific recent documents are in a file named:

~/Library/Preferences/com.company.application.LSSharedFileList.plist

To list all these files in Terminal, enter the following:

ls -Ad Library/Preferences/* | grep LSSharedFileList

On Mac OS X 10.6, these files are (usually) in a binary format.

Use Property List Editor (Apple Developer Tools / Xcode 3) or Xcode 4 to view and edit them.

They are re-read when the application launches, not while it's running. You need to close the application while editing this file.


I guess I was bored...

#!/usr/bin/env bash

mode=$2
if [ -z "$mode" ] ; then
    echo "Usage:"
    echo "$0 <filename> ls       - list recent file entries in specified *.LSSharedFileList.plist"
    echo "$0 <filename> rm <idx> - remove recent file entry with given index from specified plist"
    exit 1
fi

if [ "$mode" != "ls" ] && [ "$mode" != "rm" ] ; then
    echo "second argument must be one of [ls, rm]"
    exit 1
fi

file=$1
if [ -z $file ] ; then
    echo "Need argument (recent items plist file)!"
    exit 1
fi
if [ ! -f $file ] ; then
    echo "File $file does not exist!"
    exit 1
fi

if [ "$mode" = "ls" ] ; then
    i=0
    cont=1
    while [ $cont ] ; do
        recentfilename=$( /usr/libexec/PlistBuddy -c "Print RecentDocuments:CustomListItems:$i:Name" $file 2>/dev/null )
        if [ "$?" -ne "0" ] ; then
            cont=
        else
            echo "$i - $recentfilename"
            i=$(( $i + 1 ))
        fi
    done
fi

if [ "$mode" = "rm" ] ; then
    i=$3
    if [[ $i =~ ^-?[0-9]+$ ]] ; then
        # argument is integer
        $( /usr/libexec/PlistBuddy -c "Delete RecentDocuments:CustomListItems:$i" $file )
    else
        echo "Expected integer, got $i as third argument"
        exit 1
    fi
fi

Usage:

$ ./editrecent.sh 
Usage:
./editrecent.sh <filename> ls       - list recent file entries in specified *.LSSharedFileList.plist
./editrecent.sh <filename> rm <idx> - remove recent file entry with given index from specified plist


$ ./editrecent.sh Library/Preferences/com.macromates.textmate.LSSharedFileList.plist ls
0 - rcd
1 - artifactory.sh
2 - py.py
3 - iTunes Music Library.xml
4 - iTunes Library.xml
5 - gradle-proxy-support.diff
6 - DefaultGradlePropertiesLoader.java
7 - DefaultGradlePropertiesLoader-proxy.java
8 - gradle-proxy-support.patch
9 - DefaultKeyBinding.dict
10 - DefaultKeyBindings.dict

$ ./editrecent.sh Library/Preferences/com.macromates.textmate.LSSharedFileList.plist rm 3

$ ./editrecent.sh Library/Preferences/com.macromates.textmate.LSSharedFileList.plist ls
0 - rcd
1 - artifactory.sh
2 - py.py
3 - iTunes Library.xml
4 - gradle-proxy-support.diff
5 - DefaultGradlePropertiesLoader.java
6 - DefaultGradlePropertiesLoader-proxy.java
7 - gradle-proxy-support.patch
8 - DefaultKeyBinding.dict
9 - DefaultKeyBindings.dict
share|improve this answer
    
Ha ha, thanks for the script! Extremely helpful! :) –  Dave Gallagher Jun 6 '11 at 19:53
    
I know it was a while back but I'm just now grabbing this script. Thanks a lot for taking the time to write it up. –  Rob Jan 4 at 23:26
    
@Rob You're welcome. Note that this was written when OS X 10.6 Snow Leopard was the current release, so things might have changed since then. –  Daniel Beck Jan 4 at 23:45
add comment

What you're asking for is not a supported feature.

However, there are instructions suggesting it is possible to remove individual items by editing /Users/YOURUSERNAME/Library/Preferences/com.apple.recentitems.plist, then logging out and back in.

That file is for the system-wide history though; I wasn't able to find a plist specifically for Preview history. Assuming you're running Leopard or newer, the plist file is binary, so a basic text editor won't handle it. Text Wrangler is a free editor that can handle binary plists.

Source: Removing individual items from the "Recent Items" list

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.