rangement/utils/workInProgress/not_ready_functions.mjs

127 lines
3.0 KiB
JavaScript
Raw Normal View History

2023-07-01 12:35:33 +02:00
import finder from './finders'
import fs from 'node-fs'
/**
----------------------- parties non réalisées -----------------------
* work in progress
// TODO
---------------------------------------------------------------------
**/
2023-07-03 21:14:31 +02:00
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
}
2023-07-01 12:35:33 +02:00
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'
}
}
2023-07-19 10:49:38 +02:00
/**
* list all tags
* @param fileFullPath
* @returns {[]}
*/
2023-07-01 12:35:33 +02:00
function getControlledVocabularyFromFiles (fileFullPath) {
// find all tags
2023-07-19 10:49:38 +02:00
let listOfTags = []
return listOfTags;
2023-07-01 12:35:33 +02:00
}
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)
2023-07-19 10:49:38 +02:00
}