145 lines
3.5 KiB
JavaScript
145 lines
3.5 KiB
JavaScript
import finder from './finders'
|
|
import fs from 'node-fs'
|
|
import rangement_instance from '../../conf/configs'
|
|
import { TestFindFormattedDate, TestScreenShotIsFoundAndRenamed, TestTagsAreDetectedInFileName } from '../testFunctions'
|
|
|
|
/**
|
|
----------------------- parties non réalisées -----------------------
|
|
* work in progress
|
|
// TODO
|
|
---------------------------------------------------------------------
|
|
**/
|
|
|
|
class notReadyFunctions {
|
|
|
|
static LogActionRun () {
|
|
// get file which contains logs
|
|
// add an entry
|
|
// persist log file
|
|
}
|
|
|
|
static ListActions (idOfAction) {
|
|
// retrieve log of actions from file
|
|
}
|
|
|
|
static RevertAction (idOfAction) {
|
|
// select action and run all renames in the other way
|
|
}
|
|
|
|
static RevertMultipleActionsUntil (idOfAction) {
|
|
// select action and run all renames in the other way for each point in time
|
|
}
|
|
|
|
static findTemplateInFileName (fileName) {
|
|
// test all templates from configuration
|
|
}
|
|
|
|
static TestDownloadedTelegramPictureRename (fileName) {
|
|
let fileProperties = destructurateFileName(fileName)
|
|
}
|
|
|
|
static hasDifferentDateInNameThanExif (fileName) {
|
|
let foundDate = finder.findFormattedDate(fileName)
|
|
|
|
if (foundDate && foundDate != getExifCreationDate(fileName)) {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
static moveToArchive (targetDirectory, fileFullPath) {
|
|
// find current directory,
|
|
// rename file to move it
|
|
}
|
|
|
|
static getStatisticsOnArchiveFolder (fileFullPath) {
|
|
|
|
return {
|
|
foldersCount: 'TODO',
|
|
filesWithoutSemanticName: 'TODO'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* list all tags
|
|
* @param fileFullPath
|
|
* @returns {[]}
|
|
*/
|
|
static getControlledVocabularyFromFiles (fileFullPath) {
|
|
|
|
// find all tags
|
|
let listOfTags = []
|
|
|
|
return listOfTags
|
|
}
|
|
|
|
static moveToSortingFolder (fileFullPath) {
|
|
return 'TODO'
|
|
}
|
|
|
|
/**
|
|
* é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
|
|
}
|
|
|
|
static 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 {*}
|
|
*/
|
|
static getDirectories (path) {
|
|
return fs.readdirSync(path).filter(function (file) {
|
|
return fs.statSync(path + '/' + file).isDirectory()
|
|
}
|
|
)
|
|
}
|
|
|
|
static convertDateToTimeInFileName (inputDate) {
|
|
return inputDate.replace(' ', 'T')
|
|
}
|
|
|
|
static 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)
|
|
}
|
|
|
|
}
|
|
|
|
// run tests
|
|
if (rangement_instance.enableTestsLocally) {
|
|
|
|
TestTagsAreDetectedInFileName()
|
|
TestFindFormattedDate()
|
|
TestScreenShotIsFoundAndRenamed()
|
|
}
|
|
|
|
export default notReadyFunctions |