Skip navigation

Delete Finder History on Mac by Apple Scripting

1355 Views 4 Replies Latest reply: Nov 27, 2012 2:37 AM by abhi_apple RSS
abhi_apple Calculating status...
Currently Being Moderated
Nov 23, 2012 4:28 PM

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

  • Jacques Rioux Calculating status...
    Currently Being Moderated
    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.

  • MrHoffman Level 6 Level 6 (11,695 points)
    Currently Being Moderated
    Nov 24, 2012 3:37 AM (in response to abhi_apple)

    If this is for disk imaging (and I'm obviously making a large guess as to your overarching goal) then having a dedicated local administrator can be the handiest approach here.  That also keeps the riff-raff from viewing the shell command history, too.

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.