63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
/**---------------------
|
||
* @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()
|
||
|
||
|
||
function renameFile (originalFileName, fileMixedNewName) {
|
||
fs.rename(originalFileName, fileMixedNewName, function (err) {
|
||
if (err) console.log('rename ERROR: ' + err)
|
||
})
|
||
}
|
||
|
||
|
||
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
|
||
}
|
||
|
||
// run tests
|
||
if (enableTestsLocally) {
|
||
|
||
TestTagsAreDetectedInFileName()
|
||
TestFindFormattedDate()
|
||
TestScreenShotIsFoundAndRenamed()
|
||
}
|
||
if (reportStatistics || mini_arguments.stats) {
|
||
finder.reportStatistics()
|
||
} |