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

10.6: Clear Finder's Recent Folders list at shut down Desktop
Snow Leopard only hintI use the following method to automatically clean, at shut down time, the entries in the Finder's Go » Recent Folders menu entry. It cost me some work, but eventually it worked. Open Terminal and do the following:
$ cd /etc/
$ sudo nano rc.shutdown.local
When prompted, enter your admin password. In the nano editor, add the following lines (assuming the file doesn't yet exist):
#!/bin/bash

cd /Users/your_user/Library/Preferences/
defaults delete /Users/your_user/Library/Preferences/com.apple.finder FXRecentFolders
chown your_user:your_group com.apple.finder.plist
And now some explanation. your_user is obviously the short name of the user whose Finder preference file you want to edit. your_group is the group your user belongs to -- this is usually staff.

The chown command is needed because these commands are executed by the script as root. So the defaults delete command changes the ownership of the com.apple.finder.plist file, resulting in the loss of your Finder's preferences at reboot. For the same reason, the commands specify the full path to files, because the script isn't running as your user.

The rc.shutdown.local file does not need to be set as executable. It works like it is, but please remember to reboot twice after any change in order to see the effects.

[robg adds: I haven't tested this one. To confirm your user's group membership, you can use groups (which has technically been replaced by the less-obvious id -Gn, but still works in 10.6).]
    •    
  • Currently 2.53 / 5
  You rated: 1 / 5 (19 votes cast)
 
[13,541 views]  

10.6: Clear Finder's Recent Folders list at shut down | 8 comments | Create New Account
Click here to return to the '10.6: Clear Finder's Recent Folders list at shut down' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Clear Finder's Recent Folders list at shut down
Authored by: AJB on Feb 04, '10 01:04:09PM

Why would anyone want to do this at all, let alone on every shutdown?



[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: V.K. on Feb 06, '10 07:19:04AM
Why would you want to do this at all? And if you do want to do it for whatever reason I would suggest using a logout hook instead of a shutdown item. This would run on logout instead of shutdown which is much more appropriate for this task.

[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: ruggix on Feb 08, '10 05:17:57AM
Ok guys. Since you cannot imagine any useful application of this hint, let me just explain a little more the purpose of such a procedure. Imagine you have created a hidden folder or, even more an encrypted disk image, to store your very secret "work documents". You need to get rid of any history otherwise there would be tracks of your hidden folder. You can easily disable the history for most recent applications, files and folders located in the Apple menu (by System Preferences-> appearance) but not the Recent Folders list in the "Go" menu. On this forum I found this solution but I thought it was not so efficient to have a crontab job running every minute. This one works like a charm, the shutdown process has not get longer and the execution is completely invisible. By the way, since I am rather new to the Mac world and I would like to learn more, could you explain me please why a LogoutHook would be more appropriate than this? Is the rc.shutdown solution somehow deprecated? Thank you all. Bye

[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: Zim on Feb 08, '10 09:27:31AM

a) thanks for the hint.. it gave me ideas for something similar I wanted to accomplish.

b) as for logout vs. shutdown.. I don't know but am guessing/asking, it strikes me that a logout item should run at user privilege level, where a shutdown would need admin level (as it affects all users)

c) as for folks that ask why.. hey if a hint does not apply to you, just move along.. nothing for you to see.



[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: V.K. on Feb 09, '10 06:03:37PM

a logout hook is more appropriate because it runs on every logout rather than just shutdown. it's also easier to customize on a multi-user system as you can reference the current user as $1 in a logout hook script.



[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: Zim on Feb 08, '10 03:05:12PM

2 questions..

let's say you wanted to do this just as a script (not just at logout)

a) as written, when I do these steps, my Recent Folders menu is not cleared in the Finder

b) could this be re-written as
defaults delete /Users/$USER/Library/Preferences/com.apple.finder FXRecentFolders
chown $USER:$GROUP /Users/$USER/Library/Preferences/com.apple.finder.plist

(I'm a tcsh guy, so not certain if $USER/$GROUP work in bash (they work for me in tcsh).



[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: ruggix on Feb 09, '10 12:57:39PM
Hi Zim, I try to answer your questions: a) if you simply run the script it does not work because it needs a Finder restart to update, since Finder keeps its preferences in the cache . So to see the effect of the "defaults delete" command you should launch the following command: sudo killall FInder This is the reason why I wanted the script to run at shutdown and not at login, just to avoid the killall command. b)I think you cannot rewrite it like this. As a matter of fact the script is executed by "root" and not by your_user so the variables $USER and $GROUP would not be yours but the one of root's environment. Rather than this, I would try to follow the logouthook suggestion but I haven't tried it yet: in this way the script is executed by your user at logout, so the defaults command does not need the full path but just com.apple.finder and the chown command is not needed at all. Just one more hint. If you want to clear the content of the "Go to folder" messagebox (cmd+G) add the following before the chown: defaults write /Users/Your_User/Library/Preferences/com.apple.finder GoToField ''

[ Reply to This | # ]
10.6: Clear Finder's Recent Folders list at shut down
Authored by: Zim on Feb 09, '10 02:30:23PM
I just tested and this works... save these lines to a file XYZ

defaults delete /Users/$USER/Library/Preferences/com.apple.finder FXRecentFolders
chown ${USER}:${GROUP} /Users/$USER/Library/Preferences/com.apple.finder.plist
sudo killall Finder


then

source XYZ

(best to put in $USER/bin if that is in one's path)

[ Reply to This | # ]