Skip to content

Instantly share code, notes, and snippets.

@brandonpittman
Last active December 22, 2015 17:18
Show Gist options
  • Save brandonpittman/6505287 to your computer and use it in GitHub Desktop.
Save brandonpittman/6505287 to your computer and use it in GitHub Desktop.
Will zero out all selected files in Finder.app. Use with caution.
set iconFile to POSIX file "/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns/"
tell application "Finder"
set theFiles to get selection
set theCount to count every item of theFiles
if theCount is 0 then
display alert "No files are currently selected." as warning
return
end if
if theCount is 1 then
set theCount to "1 file"
else
set theCount to (theCount & " files") as text
end if
display dialog theCount & " will be erased. Are you sure you want to erase them?" with title "File Eraser 1.0" with icon iconFile
repeat with f in theFiles
set f to f as alias
set f to POSIX path of f
do shell script "cat /dev/null > \"" & f & "\""
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment