import finder from './finders' import fs from 'node-fs' /** ----------------------- parties non réalisées ----------------------- * work in progress // TODO --------------------------------------------------------------------- **/ 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) } function hasDifferentDateInNameThanExif (fileName) { let foundDate = finder.findFormattedDate(fileName) if (foundDate && foundDate != getExifCreationDate(fileName)) { return true } return false } function moveToArchive (targetDirectory, fileFullPath) { // find current directory, // rename file to move it } function getStatisticsOnArchiveFolder (fileFullPath) { return { foldersCount: 'TODO', filesWithoutSemanticName: 'TODO' } } function getControlledVocabularyFromFiles (fileFullPath) { let controlledVocabulary = ['TODO'] // find all tags return controlledVocabulary } function moveToSortingFolder (fileFullPath) { return 'TODO' } /** * écrit un nouveau nom de fichier formatté * @param convertedToName * @param originalFileName * @returns {*} */ function mixDateNameWithFileName (convertedToName, originalFileName) { // enlever l'ancien timestamp si il existe // ajouter en début de nom le nouveau timestamp avec un espace et conserver le reste du nom return originalFileName } function TestMixingName () { let fileMixedNewName = mixDateNameWithFileName(convertedToName, originalFileName) console.log('new name', fileMixedNewName) if (fileMixedNewName !== originalFileName) { console.log('renommage =>', fileMixedNewName) // renameFile(originalFileName, fileMixedNewName) } } /** * obtenir une liste des dossiers uniquement dans le dossier courant * @param path * @returns {*} */ function getDirectories (path) { return fs.readdirSync(path).filter(function (file) { return fs.statSync(path + '/' + file).isDirectory() }) } function convertDateToTimeInFileName (inputDate) { return inputDate.replace(' ', 'T') } function testthings(){ // let list = getDirectories(pathFolder) // console.log('list', list) let originalFileName = '2015-04-30T09.09.02 -- scan papier.jpg' let formattedDatePIMBefore = finder.findFormattedDate(originalFileName) console.log('formattedDatePIMBefore', formattedDatePIMBefore) let creationDateFound = finder.getExifCreationDate(pathFolder + '/' + originalFileName) let convertedToName = '' if (creationDateFound) { convertedToName = convertDateToTimeInFileName(creationDateFound) } console.log('convertedToName', convertedToName) }