2023-07-01 12:35:33 +02:00
|
|
|
import finder from './finders'
|
|
|
|
import fs from 'node-fs'
|
2023-07-19 12:32:13 +02:00
|
|
|
import rangement_instance from '../../conf/configs'
|
|
|
|
import { TestFindFormattedDate, TestScreenShotIsFoundAndRenamed, TestTagsAreDetectedInFileName } from '../testFunctions'
|
2023-07-01 12:35:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
----------------------- parties non réalisées -----------------------
|
|
|
|
* work in progress
|
|
|
|
// TODO
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
**/
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
class notReadyFunctions {
|
2023-07-03 21:14:31 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static LogActionRun () {
|
|
|
|
// get file which contains logs
|
|
|
|
// add an entry
|
|
|
|
// persist log file
|
|
|
|
}
|
2023-07-03 21:14:31 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static ListActions (idOfAction) {
|
|
|
|
// retrieve log of actions from file
|
|
|
|
}
|
|
|
|
|
|
|
|
static RevertAction (idOfAction) {
|
|
|
|
// select action and run all renames in the other way
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static RevertMultipleActionsUntil (idOfAction) {
|
|
|
|
// select action and run all renames in the other way for each point in time
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static findTemplateInFileName (fileName) {
|
|
|
|
// test all templates from configuration
|
2023-07-01 12:35:33 +02:00
|
|
|
}
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static TestDownloadedTelegramPictureRename (fileName) {
|
|
|
|
let fileProperties = destructurateFileName(fileName)
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static hasDifferentDateInNameThanExif (fileName) {
|
|
|
|
let foundDate = finder.findFormattedDate(fileName)
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
if (foundDate && foundDate != getExifCreationDate(fileName)) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
2023-07-01 12:35:33 +02:00
|
|
|
}
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static moveToArchive (targetDirectory, fileFullPath) {
|
|
|
|
// find current directory,
|
|
|
|
// rename file to move it
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static getStatisticsOnArchiveFolder (fileFullPath) {
|
2023-07-19 10:49:38 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
return {
|
|
|
|
foldersCount: 'TODO',
|
|
|
|
filesWithoutSemanticName: 'TODO'
|
|
|
|
}
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
/**
|
|
|
|
* list all tags
|
|
|
|
* @param fileFullPath
|
|
|
|
* @returns {[]}
|
|
|
|
*/
|
|
|
|
static getControlledVocabularyFromFiles (fileFullPath) {
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
// find all tags
|
|
|
|
let listOfTags = []
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
return listOfTags
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static moveToSortingFolder (fileFullPath) {
|
|
|
|
return 'TODO'
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
/**
|
|
|
|
* écrit un nouveau nom de fichier formatté
|
|
|
|
* @param convertedToName
|
|
|
|
* @param originalFileName
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
static 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
|
2023-07-01 12:35:33 +02:00
|
|
|
}
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static TestMixingName () {
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
let fileMixedNewName = mixDateNameWithFileName(convertedToName, originalFileName)
|
|
|
|
console.log('new name', fileMixedNewName)
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
if (fileMixedNewName !== originalFileName) {
|
|
|
|
console.log('renommage =>', fileMixedNewName)
|
|
|
|
// renameFile(originalFileName, fileMixedNewName)
|
|
|
|
}
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
/**
|
|
|
|
* obtenir une liste des dossiers uniquement dans le dossier courant
|
|
|
|
* @param path
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
|
|
|
static getDirectories (path) {
|
|
|
|
return fs.readdirSync(path).filter(function (file) {
|
|
|
|
return fs.statSync(path + '/' + file).isDirectory()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static convertDateToTimeInFileName (inputDate) {
|
|
|
|
return inputDate.replace(' ', 'T')
|
|
|
|
}
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
static testthings () {
|
|
|
|
// let list = getDirectories(pathFolder)
|
2023-07-01 12:35:33 +02:00
|
|
|
// console.log('list', list)
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
let originalFileName = '2015-04-30T09.09.02 -- scan papier.jpg'
|
|
|
|
let formattedDatePIMBefore = finder.findFormattedDate(originalFileName)
|
|
|
|
console.log('formattedDatePIMBefore', formattedDatePIMBefore)
|
2023-07-01 12:35:33 +02:00
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
let creationDateFound = finder.getExifCreationDate(pathFolder + '/' + originalFileName)
|
|
|
|
let convertedToName = ''
|
|
|
|
if (creationDateFound) {
|
|
|
|
convertedToName = convertDateToTimeInFileName(creationDateFound)
|
|
|
|
}
|
|
|
|
console.log('convertedToName', convertedToName)
|
2023-07-01 12:35:33 +02:00
|
|
|
}
|
2023-07-19 11:11:43 +02:00
|
|
|
|
2023-07-19 10:49:38 +02:00
|
|
|
}
|
|
|
|
|
2023-07-19 12:32:13 +02:00
|
|
|
// run tests
|
|
|
|
if (rangement_instance.enableTestsLocally) {
|
|
|
|
|
|
|
|
TestTagsAreDetectedInFileName()
|
|
|
|
TestFindFormattedDate()
|
|
|
|
TestScreenShotIsFoundAndRenamed()
|
|
|
|
}
|
|
|
|
|
2023-07-19 11:11:43 +02:00
|
|
|
export default notReadyFunctions
|