title: Applescript: Get filenames in folder without extension
body: <p>I can get the names of all files in a folder by doing this:</p>
  
  <pre><code>tell application "Finder"
      set myFiles to name of every file of somePath
  end tell
  </code></pre>
  
  <p>How can I change the strings in <code>myFiles</code> so that they do not include the file extension?</p>
  
  <p>I could for example get <code>{"foo.mov", "bar.mov"}</code>, but would like to have  <code>{"foo", "bar"}</code>.</p>
  
  <hr>
  
  <h2>Current solution</h2>
  
  <p>Based on the accepted answer I came up with the code below. Let me know if it can be made cleaner or more efficient somehow.</p>
  
  <pre><code>-- Gets a list of filenames from the
  on filenames from _folder
  
      -- Get filenames and extensions
      tell application "Finder"
          set _filenames to name of every file of _folder
          set _extensions to name extension of every file of _folder
      end tell
  
      -- Collect names (filename - dot and extension)
      set _names to {}
      repeat with n from 1 to count of _filenames
  
          set _filename to item n of _filenames
          set _extension to item n of _extensions
  
          if _extension is not "" then
              set _length to (count of _filename) - (count of _extension) - 1
              set end of _names to text 1 thru _length of _filename
          else
              set end of _names to _filename
          end if
  
      end repeat
  
      -- Done
      return _names
  end filenames
  
  -- Example usage
  return filenames from (path to desktop)
  </code></pre>