Created
March 24, 2018 14:41
-
-
Save anypossiblew/fc81ceade541f334c71633f63e9ae339 to your computer and use it in GitHub Desktop.
picasa filter star
This file contains hidden or 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
| 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