Created
April 14, 2016 04:12
-
-
Save jedireza/4d6c05576756a45a63137f3754121af3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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