Iterate through local files using the FileSystem module with PhantomJS

The snippet below will iterate through the ./images directory and log all of the files found to the console. It uses the FileSystem module and is meant to be used with PhantomJS.

const fs = require('fs');

const dir = fs.workingDirectory + fs.separator + "images/";
const images = fs.list(dir);

// loop through files and folders
for (let i = 0; i < images.length; i++) {
    const imagePath = imageDirectory + images[i];
    if (fs.isFile(imagePath)) {

more Node.js posts

more JavaScript posts