scripts/rangement/workInProgress/not_ready_functions.mjs

103 lines
2.5 KiB
JavaScript
Raw Normal View History

2023-06-29 18:58:08 +02:00
import finder from './finders'
import fs from 'node-fs'
/**
----------------------- parties non réalisées -----------------------
2023-06-29 18:59:12 +02:00
* work in progress
// TODO
2023-06-29 18:58:08 +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'
}
}
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)
}