Skip to content

Instantly share code, notes, and snippets.

@anypossiblew
Created March 24, 2018 14:41
Show Gist options
  • Select an option

  • Save anypossiblew/fc81ceade541f334c71633f63e9ae339 to your computer and use it in GitHub Desktop.

Select an option

Save anypossiblew/fc81ceade541f334c71633f63e9ae339 to your computer and use it in GitHub Desktop.
picasa filter star
const fs = require('fs');
const path = require('path');
let basePath = process.argv[2]||".";
var data = fs.readFileSync(basePath + "/.picasa.ini", "utf-8");
let files = data.split("\r\n");
let fileName = "";
let starFiles = {};
files.forEach((line)=> {
if(!line) return;
let fileNameMatch = line.match(/\[(.*)\]/);
if(fileNameMatch) {
fileName = fileNameMatch[1];
starFiles[fileName] = {};
}else {
let starMatch = line.match(/(.*)=(.*)/);
if(starMatch) {
starFiles[fileName][starMatch[1]] = starMatch[2];
}
}
});
console.log(starFiles);
fs.readdir(basePath, (err, files)=> {
files.forEach((file)=> {
let cr2Match = file.match(/(.*)\.CR2/);
if(cr2Match) {
if(!starFiles[cr2Match[1]+'.JPG']||starFiles[cr2Match[1]+'.JPG'].star != 'yes') {
fs.unlinkSync(basePath +'/' + file);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment