MacOS – Terminal script for compare and delete unused Library folder and files

library-managementmacosterminal

I am cleaning up my Library from junk on an MacBook Air (MacOS 10.8.4). Over time I have downloaded, installed and deleted Applications (they are no longer in my Applications folder).

However, lots of them (some I no longer have clue what they are) are still in my Library in different places.

The ones I can find and recognize I can delete manually (like Wondershare)…but!

Question: Is there a safe and clean way using Terminal or other application, to compare my Applications folder for installed applications to the Library and delete unused folders and files.

In other words: If the application is NOT in my Applications folder, then it should not be in the Library.

Best Answer

Other options:

  • Sort ~/Library/Preferences or ~/Library/Containers by modification date
  • Enable calculating all sizes and sort folders by size in Finder
  • for f in ~/Library/Containers/*; do osascript -e "app id \"${f##*/}\"" &> /dev/null || echo $f; done
  • cd ~/Library/Application\ Support; for d in *; do find "$d" -exec stat -f "%m $d" {} + | sort -n | tail -n1; done | sort -n
  • cd ~/Library/Preferences; find . -name \*.LSSharedFileList.plist -mtime +30 -delete; ls -rt *.plist | grep -v apple | sed 's/^/rm /'