Count Files (Ignoring Extensions)

October 11th, 2010 | Tags: , , ,

When downloading TV episodes and the subtitle files that go with them, it is useful to know if all of the filenames match (with the exception of the extension, of course). This script does just that:

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