diff --git a/index.mjs b/index.mjs index 75964fb..9148a60 100644 --- a/index.mjs +++ b/index.mjs @@ -31,6 +31,7 @@ parseArguments() function renameFile (originalFileName, fileMixedNewName) { fs.rename(originalFileName, fileMixedNewName, function (err) { + console.log('name changed', fileMixedNewName) if (err) console.log('rename ERROR: ' + err) }) } @@ -64,6 +65,12 @@ function shouldWeChangeName (structureForFile) { console.log('\n ancien nom :', structureForFile.fileNameOriginal) // console.log(' nouveau nom:', foundDate +structureForFile.freeText + structureForFile.tags.join(tagSeparator) + structureForFile.extension ) console.log(' nouveau nom:', newName) + if(! mini_arguments.dryRun){ + renameFile(structureForFile.fullPath, structureForFile.folderPath + newName) + } + else{ + console.log('no renaming for real, this is a dry run') + } } else { console.log(' rien à changer') } diff --git a/package.json b/package.json index 289f45a..7f5a860 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "sorting utilities and file tagging using PIM methodology of Karl Voit", "main": "index.mjs", "scripts": { - "start": "nodemon index.mjs testFiles/2sqdf45s5g456ghdf.jpg", + "start": "node index.mjs", "devine": "node index.mjs", "test": "jest" }, diff --git a/testFiles/2sqdf45s5g456ghdf.jpg b/testFiles/2020-06-21T14:27:19 2sqdf45s5g456ghdf.jpg similarity index 100% rename from testFiles/2sqdf45s5g456ghdf.jpg rename to testFiles/2020-06-21T14:27:19 2sqdf45s5g456ghdf.jpg diff --git a/workInProgress/not_ready_functions.mjs b/workInProgress/not_ready_functions.mjs index fd67409..278c840 100644 --- a/workInProgress/not_ready_functions.mjs +++ b/workInProgress/not_ready_functions.mjs @@ -8,6 +8,22 @@ import fs from 'node-fs' --------------------------------------------------------------------- **/ +function LogActionRun(){ + // get file which contains logs + // add an entry + // persist log file +} + +function ListActions(idOfAction){ + // retrieve log of actions from file +} +function RevertAction(idOfAction){ + // select action and run all renames in the other way +} +function RevertMultipleActionsUntil(idOfAction){ + // select action and run all renames in the other way for each point in time +} + function TestDownloadedTelegramPictureRename (fileName) { let fileProperties = destructurateFileName(fileName) }