Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

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

** TL;DR

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

js
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 :

js
const fileList = getImages('/some/directory/path')