Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete PreSonus UC Files on OS X 10.5 and 10.6
on run {input, parameters}
-- Setup the list of the main files to be deleted
set searchList to {¬
POSIX file ("/Applications/Universal Control.app") as text, ¬
POSIX file ("/Applications/FireStudio Control Console.app") as text, ¬
POSIX file ("/Applications/FireControl.app") as text, ¬
POSIX file ("/Applications/FireStudio Lightpipe Mixer.app") as text, ¬
POSIX file ("/Applications/StudioLive.app") as text, ¬
POSIX file ("/Library/Application Support/PaeFireStudio") as text, ¬
POSIX file ("/Library/Application Support/PreSonus") as text, ¬
POSIX file ("/Library/Audio/MIDI Drivers/PaeFireStudioMIDIDriver.plugin") as text, ¬
POSIX file ("/Library/Preferences/PaeFireStudio.startup") as text, ¬
POSIX file ("/Library/Receipts/PreSonusUniversalControl.pkg") as text, ¬
POSIX file ("/Library/StartupItems/PaeFireStudio") as text, ¬
POSIX file ("/System/Library/Extensions/PaeFireStudio.kext") as text, ¬
POSIX file ("/Users/" & (system attribute "USER") & "/Library/Caches/Juce/juceAppLock_Universal Control") as text, ¬
POSIX file ("/Users/" & (system attribute "USER") & "/Library/Caches/Juce/Universal Control") as text, ¬
POSIX file ("/Users/" & (system attribute "USER") & "/Library/Preferences/FireControlSettings.settings") as text, ¬
POSIX file ("/Users/" & (system attribute "USER") & "/Library/PreSonus") as text ¬
}
-- Display a dialog window asking whether the user is on Snow Leopard or not to add the Snow Leopard specific files to the list explicitly.
set slButton to button returned of (display dialog "Are you currently booted into Snow Leopard, OS X 10.6? If you are unsure, click 'Cancel' below and choose 'About This Mac' from the Apple Menu in the upper left corner of your desktop." buttons {"Yes", "No", "Cancel"} default button "Cancel")
if slButton is "Yes" then
copy (POSIX file ("/private/var/db/receipts/com.presonus.pkg.Universal Control.bom") as text) to the end of searchList
copy (POSIX file ("/private/var/db/receipts/com.presonus.pkg.Universal Control.plist") as text) to the end of searchList
end if
set tc to count searchList
set deleted_files_and_folders to {}
set not_deleted_files_and_folders to {}
set not_found_files to {}
-- Iterate through the list of files and move them to the trash
repeat with i from 1 to tc
set file_or_folder to (item i of searchList)
set file_or_folder_path to POSIX path of file_or_folder
tell application "Finder"
if exists file file_or_folder then
try
delete file file_or_folder
display dialog ("Successfully deleted: " & (ASCII character 10) & file_or_folder_path) buttons {"OK"} default button "OK"
copy file_or_folder_path to the end of deleted_files_and_folders
on error
display dialog ("[Error] Unable to delete: " & (ASCII character 10) & file_or_folder_path) buttons {"OK"} default button "OK"
copy file_or_folder_path to the end of not_deleted_files_and_folders
end try
else if exists folder file_or_folder then
try
delete (file_or_folder as alias)
display dialog ("Successfully deleted: " & (ASCII character 10) & file_or_folder_path) buttons {"OK"} default button "OK"
copy file_or_folder_path to the end of deleted_files_and_folders
on error
display dialog ("[Error] Unable to delete: " & (ASCII character 10) & file_or_folder_path) buttons {"OK"} default button "OK"
copy file_or_folder_path to the end of not_deleted_files_and_folders
end try
else
copy file_or_folder_path to the end of not_found_files
display dialog ("[Warning] Unable to find the following file: " & (ASCII character 10) & file_or_folder_path) buttons {"OK"} default button "OK"
end if
end tell
end repeat
-- Just setting this string here so we only have to edit in one place, keepin' it DRY folks
set final_instructions to "Please empty your trash, reboot your computer, repair your disk permissions, reset your PRAM, and re-install Universal Control"
--separates the items in the list by joining them with the specified characters
set AppleScript's text item delimiters to ASCII character 10
-- Give some feedback to the user about what was done to their system
if not deleted_files_and_folders = {} then
display dialog ("Successfully deleted: " & (ASCII character 10) & deleted_files_and_folders) buttons {"OK"} default button "OK"
end if
if not not_found_files = {} then
display dialog ("Unable to find the following list of files. " & (ASCII character 10) & not_found_files) buttons {"OK"} default button "OK"
end if
if not not_deleted_files_and_folders = {} then
display dialog ("Found, but unable to delete the following files because of an error. Please attempt to delete these files manually: " & (ASCII character 10) & not_deleted_files_and_folders & (ASCII character 10) & (ASCII character 10) & final_instructions) buttons {"OK"} default button "OK"
else
display dialog ("All items that were found were successfully deleted. " & final_instructions) buttons {"OK"} default button "OK"
end if
-- Reset the lists to their default delimiter of nothing
set AppleScript's text item delimiters to ""
-- Display a dialog window asking whether to empty trash or not
set theButton to button returned of (display dialog "Would you like to empty the trash?" with icon caution buttons {"Empty Trash", "Cancel"} default button "Cancel" giving up after 10)
if theButton is "Empty Trash" then
tell application "Finder"
empty trash
end tell
end if
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.