home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Getting The List Of Image Files In A Directory With Photoshop Scripting

February 2014

** TL;DR

This function returns a list of image files in a given directory:

Code
function getImages(sourceDir) {
  const files = new Array()
  const rawFiles = Folder(sourceDir).getFiles()
  for (var i = 0; i < rawFiles.length; i++) {
    if (rawFiles[i].name.match(/\.(psd|jpg|gif|png)$/i) !== null) {
      files.push(rawFiles[i])
    }
  }
  return files
}

Then call it like this:

Code
const fileList = getImages('/some/directory/path')
═══ § ═══