From e81cd005e77188c819eef15c1a54bf09d5c720f4 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Wed, 24 Jun 2020 12:34:11 -0400 Subject: [PATCH] copy file with orginal name if no exif exists --- index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index.js b/index.js index e3f741e..f632d53 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,11 @@ fs.readdir(dir, (err, files) => { if (error){ // console.log('Error: '+error.message); // console.log(file); + fs.copyFile(dir+file, '/Users/matthuntington/Downloads/reorg/'+file, fs.constants.COPYFILE_EXCL, (err) => { + if(err){ + console.log(err); + } + }); } else{ if(exifData.exif.CreateDate){ @@ -20,6 +25,14 @@ fs.readdir(dir, (err, files) => { console.log(err); } }); + } else { + // console.log(exifData); + // console.log(file); + fs.copyFile(dir+file, '/Users/matthuntington/Downloads/reorg/'+file, fs.constants.COPYFILE_EXCL, (err) => { + if(err){ + console.log(err); + } + }); } } });