Is There An Easier Way to Check File Extension?

Hello,

I'm using this macro to open PDFs (and only PDFs) in PDFpen. Is there an easier way to check the file extension first? It works, but it seems too complex and is slower than I'd like. Thanks!

This is the regular expression:

(?i).pdf$

It means:

(?i) =  ignore case
\. = a literal period character
pdf = the literal characters pdf
$ = end of string

Hey Christian,

Sure. A little AppleScript goes a long way in this instance.

-Chris

--------------------------------------------------------------------------------
tell application "Finder"
   set finderSelectionList to selection as alias list
   if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
   
   repeat with i in finderSelectionList
      if kind of i ≠ "PDF" then
         set contents of i to 0
      end if
   end repeat
   
end tell

set finderSelectionList to aliases of finderSelectionList

tell application "PDFpen"
   if not running then
      run
      delay 0.25
   end if
   
   activate
   
   open finderSelectionList
   
end tell
--------------------------------------------------------------------------------