Count Files (Ignoring Extensions) v1.1

October 17th, 2010 | Tags: , , ,

I knew when I created the original script, there would be times when I needed to see the raw output (rather than just the count). This turned out to be every time the count turned out to be a number I didn’t expect. So I updated the script to v1.1 and added a “Show Details…” button. (To keep from having to duplicate the command, I also re-factored the generation of the command slightly.)

tell application "Finder"
  set cmd to "ls " & (quoted form of (POSIX path of (insertion location as string))) & ¬
    " | sed 's/\\(.*\\)\\..*/\\1/' | sed 's/\\(.*\\)\\.[^.]*/\\1/' | uniq"
  set n to (do shell script (cmd & " | wc -l"))
  set theResult to display dialog "Ignoring extensions, there are " & (n as integer) & ¬
    " unique file names in the curent folder." buttons {"Show Details…", "OK"} default button 2 ¬
    with title "Count Files v1.1 (Plaid Cow Solutions)"
  if (button returned of theResult) is not "OK" then
    tell application "TextEdit"
      set theDoc to make new document
      set the text of theDoc to (do shell script cmd)
    end tell
  end if
end tell
No comments yet.
You must be logged in to post a comment.