making sure I uploaded all my pictures to a photo printing service
//not sure if this works as it should
//diff
function arr_diff(a1, a2) {
var a = [],
diff = [];
for (var i = 0; i < a1.length; i++)
a[a1[i]] = true;
for (var i = 0; i < a2.length; i++)
if (a[a2[i]]) delete a[a2[i]];
else a[a2[i]] = true;
for (var k in a)
diff.push(k);
return diff;
}
/* Node.js App */
var walk = require('walk'),
fs = require('fs'),
options, walker,
doneArray = []; //just the numbers of the files
options = {
followLinks: false
// directories with these keys will be skipped
};
//folder to walk
walker = walk.walk("export/costco-album", options);
walker.on("names", function(root, nodeNamesArray) {
nodeNamesArray.sort(function(a, b) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
});
var removeDS = nodeNamesArray.splice(1);
removeDS.forEach(function(item) {
doneArray.push(parseInt(item.split('.')[0]));
});
console.log(doneArray);
});
walker.on("errors", function(root, nodeStatsArray, next) {
next();
});
walker.on("end", function() {
console.log("all done");
});
/* Page code to get all file names that are uploaded then sort them */
var a = jQuery('li.item'),
sorted = [];
for (var i = 0, len = a.length; i < len; i++) {
var title = jQuery(a[i]).find('.frame').attr('title'),
fmt = parseInt((title.split('.')).splice(0,2));
sorted.push(fmt);
}
var sorter = sorted.sort(function(a,b) {return b-a});
console.log(sorter);
//find duplicates
var arr = b;
var sorted_arr = arr.sort(); // You can define the comparing function here.
// JS by default uses a crappy string compare.
var results = [];
for (var i = 0; i < arr.length - 1; i++) {
if (sorted_arr[i + 1] == sorted_arr[i]) {
results.push(sorted_arr[i]);
}
}
console.log(results);