Skip to content

Instantly share code, notes, and snippets.

@pix0r
Created February 19, 2012 20:47
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 pix0r/1865701 to your computer and use it in GitHub Desktop.
Save pix0r/1865701 to your computer and use it in GitHub Desktop.
Delete *.m3u and *.pls under current Finder directory
-- Path of script:
-- tell application "Finder" to get POSIX path of ((container of (path to me)) as text)
-- Foreground Finder window:
tell application "Finder" to get POSIX path of ((the target of the front window) as text)
set currDir to quoted form of result
set cmdBase to "find " & currDir & " \\( -name \\*.m3u -or -name \\*.pls \\)"
set cmdList to cmdBase & " -exec basename {} \\;"
set cmdCount to cmdBase & " | wc -l"
set cmdDelete to cmdBase & " -exec rm -f {} \\;"
set fileList to (do shell script cmdList)
set fileCount to (do shell script cmdCount) as integer
if (fileCount = 0) then
display dialog "No playlist files found" buttons {"OK"}
else
set message to "Delete " & fileCount & " playlist files?"
display dialog message
do shell script cmdDelete
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment