Skip to content

Instantly share code, notes, and snippets.

@mkhl
Created November 28, 2008 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkhl/30084 to your computer and use it in GitHub Desktop.
Save mkhl/30084 to your computer and use it in GitHub Desktop.
Set sensible defaults for owner, permissions and quarantine flags for the dropped app bundles
on open (theItems)
set theCleanedItems to {}
repeat with theApp in theItems
set thePath to the POSIX path of theApp
fixOwner(thePath)
fixPermissions(thePath)
unquarantine(thePath)
set theCleanedItems to theCleanedItems & ("- " & the displayed name of item (theApp as string) of application "Finder")
end repeat
set theText to "Successfully cleaned:
" & (join of theCleanedItems by "
")
display dialog ¬
theText with icon 1 ¬
buttons {"OK"} default button 1
end open
on fixOwner(thePath)
do shell script "chown -R root:admin " & thePath ¬
with administrator privileges
end fixOwner
on fixPermissions(thePath)
do shell script "chmod -R ug=rwX,o=rX " & thePath ¬
with administrator privileges
end fixPermissions
on unquarantine(thePath)
do shell script "xattr -d com.apple.quarantine " & thePath ¬
with administrator privileges
end unquarantine
to join of aList by sep
local aString, delims
tell AppleScript
set delims to text item delimiters
set text item delimiters to sep
set aString to aList as string
set text item delimiters to delims
end tell
return aString
end join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment