Skip to content

Instantly share code, notes, and snippets.

@jedireza
Created April 14, 2016 04:12
Show Gist options
  • Save jedireza/4d6c05576756a45a63137f3754121af3 to your computer and use it in GitHub Desktop.
Save jedireza/4d6c05576756a45a63137f3754121af3 to your computer and use it in GitHub Desktop.
'use strict';
let fs = require('fs');
let directory = process.argv[2];
let map = {};
let duplicates = {};
fs.readdir(directory, (err, items) => {
for (let i = 0; i < items.length; i++) {
let key = items[i].toLowerCase();
if (map.hasOwnProperty(key)) {
map[key].push(items[i]);
}
else {
map[key] = [items[i]];
}
}
Object.keys(map).forEach((key) => {
if (map[key].length > 1) {
duplicates[key] = map[key];
}
});
console.log(duplicates);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment