Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Delete Finder History on Mac by Apple Scripting

Hi Everyone,


Can we delete the Finder history through an Apple Script.


I want to delete the history at these 2 paths:


1) I need to clear the history under the "Recent Items" menu which comes under the Apple icon at upper left corner of our mac screen.


2) Secondly, I need to remove the history from the below path:


Finder-->Go-->Recent Folders--> Clear Menu


Thanks in advance for helping me out.


Best,


Abhishek

Posted on Nov 23, 2012 4:28 PM

Reply
Question marked as Best reply

Posted on Nov 23, 2012 7:21 PM

Hi,


Try this:

-------------

quit application "Finder"
delay 1
set prefFolder to path to preferences as string
tell application "System Events"
      tell appearance preferences
            set x to {recent applications limit, recent documents limit, recent servers limit}
            set {recent applications limit, recent documents limit, recent servers limit} to {0, 0, 0}
            set {recent applications limit, recent documents limit, recent servers limit} to x
      end tell
      tell property list item "FXRecentFolders" of contents of property list file (prefFolder & "com.apple.finder.plist") to set value to {}
end tell
activate application "Finder"


Cons: This script quit the Finder:



Or this script:

----------------

tell application "System Events"
      tell appearance preferences
            set x to {recent applications limit, recent documents limit, recent servers limit}
            set {recent applications limit, recent documents limit, recent servers limit} to {0, 0, 0}
            set {recent applications limit, recent documents limit, recent servers limit} to x
      end tell
      tell process "Finder"
            set frontmost to true
            click last menu item of menu of menu item -4 of menu of menu bar item 6 of menu bar 1
      end tell
end tell


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

Cons: Need GUI Scripting enabled and the Finder needs to be in the foreground.

4 replies
Question marked as Best reply

Nov 23, 2012 7:21 PM in response to abhi_apple

Hi,


Try this:

-------------

quit application "Finder"
delay 1
set prefFolder to path to preferences as string
tell application "System Events"
      tell appearance preferences
            set x to {recent applications limit, recent documents limit, recent servers limit}
            set {recent applications limit, recent documents limit, recent servers limit} to {0, 0, 0}
            set {recent applications limit, recent documents limit, recent servers limit} to x
      end tell
      tell property list item "FXRecentFolders" of contents of property list file (prefFolder & "com.apple.finder.plist") to set value to {}
end tell
activate application "Finder"


Cons: This script quit the Finder:



Or this script:

----------------

tell application "System Events"
      tell appearance preferences
            set x to {recent applications limit, recent documents limit, recent servers limit}
            set {recent applications limit, recent documents limit, recent servers limit} to {0, 0, 0}
            set {recent applications limit, recent documents limit, recent servers limit} to x
      end tell
      tell process "Finder"
            set frontmost to true
            click last menu item of menu of menu item -4 of menu of menu bar item 6 of menu bar 1
      end tell
end tell


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

Cons: Need GUI Scripting enabled and the Finder needs to be in the foreground.

Delete Finder History on Mac by Apple Scripting

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.