/**--------------------- * @name tykayn Rangement * @description Rangement sorts and rename files depending on their exif data * @contact contact@cipherbliss.com --------------------- */ /** --------------------- libs --------------------- */ import fs from 'node-fs' import minimist from 'minimist' /** --------------------- custom utilities and configuration --------------------- */ import { enableTestsLocally, reportStatistics, tagSectionSeparator, tagSeparator } from './configs.mjs' import { TestFindFormattedDate, TestScreenShotIsFoundAndRenamed, TestTagsAreDetectedInFileName } from './testFunctions.mjs' import finder from './finder.mjs' let mini_arguments; console.log(' ') function parseArguments () { mini_arguments = minimist(process.argv.slice(2)) // console.log('arguments', mini_arguments) } parseArguments() const pathFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/tout' const sortingFolder = '/home/poule/encrypted/stockage-syncable/photos/a_dispatcher' function renameFile (originalFileName, fileMixedNewName) { fs.rename(originalFileName, fileMixedNewName, function (err) { if (err) console.log('rename ERROR: ' + err) }) } const fileDefinition = { dateStamp: '', freeText: '', tags: [], extension: '', } function makeFileNameFromProperties (fileProperties) { return finder.cleanSpaces(fileProperties.dateStamp + ' ' + fileProperties.freeText + ' ' + tagSectionSeparator + ' ' + fileProperties.tags.join(tagSeparator) + fileProperties.extension) } function appendFileName (fileProperties, newText) { fileProperties.freeText = finder.cleanSpaces(fileProperties.freeText + ' ' + newText) return fileProperties } function prependFileName (fileProperties, newText) { fileProperties.freeText = finder.cleanSpaces(newText + ' ' + fileProperties.freeText) return fileProperties } /** * work in progress * */ // run tests if (enableTestsLocally) { TestTagsAreDetectedInFileName() TestFindFormattedDate() TestScreenShotIsFoundAndRenamed() } if (reportStatistics || mini_arguments.stats) { finder.reportStatistics() }