Remove Applications installed based on date installed

rcarey
New Contributor III

I'll preface with the fact that I have little or no skill with scripting. Often times I can read a script and understand some components of it, but that's about it.

That said, I've been doing some digging online trying to find a script to use in Self Service that will allow me to delete an Applications installed by a user (this will be utilized on loaner computers). I figure sorting by date created would be an easy way to determine what should be deleted and what shouldn't be, but can't seem to find anything in my search.

Does anyone have anything like this?

2 REPLIES 2

mm2270
Legendary Contributor III

Would you care to elaborate on why something like this would be needed? Is this a case of freeing up space on disk perhaps? If so, there may be some other things to consider first to help clear up some space, like clearing out logs and caches for example.

That being said, Spotlight keeps track of when applications are added, but keep in mind, upgrades to those programs may reset the date added values on them. Spotlight can be used in the shell, with mdls and mdfind For example, to get a date added for a program, such as "Firefox", use something like

mdls /Applications/Firefox.app -name kMDItemDateAdded | awk '{print $3,$4}'

mdfind can locate all applications in a specific directory

mdfind -onlyin /Applications 'kMDItemKind == "Application"'

You can find ways to combine these to locate all applications in a path and then find the date added for each one.

rcarey
New Contributor III

The reason we want to employ something like this is to avoid any issues when a new user checks the computer out, and tries to open an application that is licensed to another person. I already have a good way to delete the user profile, but it'd be nice to be able to clear out any applications that get downloaded while they have checked the computer out.

Ideally it would be something similar to Deep Freeze, but just not at Restart. If I had the ability to push a reset using something like Deep Freeze, that would be the best solution.