Need a script to delete files

Hi

Can someone advise me on how to create a script to delete certain files from a users home account at logout?

The files that I want deleting are .plist files in there ~/lib.../preferences folder, this is so I can ensure that all users will have the same settings for certain files next time they login again.


Thanks

Mac OS X (10.6.7)

Posted on Aug 14, 2011 3:28 AM

Reply
6 replies

Aug 14, 2011 11:54 AM in response to baltwo

That being said, if you you still really want to do this you can create a logout hook and write a shell script to remove the files. See "About Daemons and Services", Appendix B on writing a logout hook.


But a far easier way is to create Account's login item that will cause a shell script to be launched to delete the files. You can encapsulate the shell script so it runs as an application that can be added to the Login Items. One such encapsulator is Platypus.


Note, rather than delete them, if you want to ensure all the specific plists have specific settings, then create a master set of them and copy the master set into the Preferences directory (being careful to observe ownership and permissions settings of course).

Aug 14, 2011 12:16 PM in response to X423424X

X423424X wrote:


Note, rather than delete them, if you want to ensure all the specific plists have specific settings, then create a master set of them and copy the master set into the Preferences directory (being careful to observe ownership and permissions settings of course).

Doing that won't achieve the OP's goal of reseting things to defaults on each log in. IMO, it's an exercise in futility and smacks of being a control freak.

Aug 14, 2011 12:32 PM in response to baltwo

He may be a control freak or he might have some valid reason for doing what he wants (e.g., a teacher who wants all his students to have the same settings) but my philosophy in these discussions is to not editorialize on why a poster might want what s/he wants. I might question it. But generally I just try to answer what is being asked and possibly provide alternatives.


As for my suggestion, if the plists in question are reset to what what s/he wants (from a master set of plists created with settings s/he wants) I see no difference if they are set when logging out or logging in so long as they are what s/he wants by the time the apps in question are launched.

Aug 14, 2011 12:34 PM in response to baltwo

Lol, it's not so much of being a control freak, it more due to the fact that we have over 2000 users on a windows AD. All users can login and not all users can be trusted to have a 'sensible' wall paper suitable for an educational environment.


I've alread sorted out the default user template, so that when the users plist files are deleted it will take in the default settings again. Yes your right that importing the settings in after the user logs in will not have the desire affect, hence why I'm thinking of removing settings, so that the user can change them as much as they wish and they will be reset next time.


IMHO; it's more of a case of trolling, rather than being helpful.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Need a script to delete files

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