From 16e4a8a4e8f8e459575711f22621ae13f68a6738 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 10 Sep 2023 12:16:11 +0200 Subject: [PATCH] add gopro restore name options --- README.md | 10 +++++++++- tests/finder.test.js | 4 ++-- utils/finder.ts | 40 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e547dff..6fe40d1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,11 @@ utiliser le setup pour mettre en place l'architecture de dossiers de rangement. ## options * -n , dry-run, ne pas renommer * --photos-folder, spécifie un dossier pour les photos +* --gopro-restore-name, ne garde que les descriptions de fichier et l'extension +* --remove-timestamp, enlève le timestamp en début de nom de fichier. +* --remove-free-text, enlève le texte libre entre le timestamp et les tags. +* --remove-tags, enlève les tags. +* --remove-extension, enlève l'extension finale. # English ## This is a work in progress @@ -29,7 +34,8 @@ utiliser le setup pour mettre en place l'architecture de dossiers de rangement. "npm start" gives you a demo of what Rangement can do, but this is not a production ready package yet. # done - +* Rename with exif data +* New file name typology as Personal Information Management defined by Karl Voit and its Phd thesis. * Handle verbosity levels in logs - log.trace(msg) - log.debug(msg) @@ -40,6 +46,8 @@ utiliser le setup pour mettre en place l'architecture de dossiers de rangement. # Roadmap * Internationalisation of console texts +* Rename with addition of folder containing. RFF https://www.cipherbliss.com/script-rff-rename-file-folder +* Controlled vocabulary handling * Proper testing * Template configuration for auto dispatching of files after rename * Handle a configuration file diff --git a/tests/finder.test.js b/tests/finder.test.js index 7aebc91..3491e51 100644 --- a/tests/finder.test.js +++ b/tests/finder.test.js @@ -1,4 +1,4 @@ -import finder from '../utils/finder' +import finder from '../utils/finder.ts' import { makeFileNameFromProperties } from '../old_index' import { expect } from '@jest/globals' @@ -140,4 +140,4 @@ describe('modifications with tags', () => { xtest('should remove with minus prefix and add tags in file name at the same time', () => { }) -}) \ No newline at end of file +}) diff --git a/utils/finder.ts b/utils/finder.ts index 1d2c7c4..887debd 100644 --- a/utils/finder.ts +++ b/utils/finder.ts @@ -197,16 +197,48 @@ export default class finder { tagPlace = ' ' + rangement_instance.tagSectionSeparator + ' ' + fileProperties.tags.join(rangement_instance.tagSeparator) } log.debug('fileProperties.dateStampExif', fileProperties.dateStampExif) + + let newName = ''; + let timestampFormatted = fileProperties.dateStampExif; + /** + * restauration de typologie de nom de fichier gopro pour faciliter les assemblages. + */ + if(this.mini_arguments['gopro-restore-name']){ + this.mini_arguments['remove-timestamp'] = true; + this.mini_arguments['remove-tags'] = true; + } + + if(this.mini_arguments['remove-tags'] ){ + tagPlace = ''; + } + if(this.mini_arguments['remove-timestamp'] ){ + timestampFormatted = ''; + } + + if(this.mini_arguments['remove-freetext'] ){ + log.debug('override remove-freetext' ) + rangement_instance.keepFreeText = false; + } + + let extension = fileProperties.extension.trim(); + + if(this.mini_arguments['remove-extension'] ){ + extension = ''; + } + let spacer = ''; - if (fileProperties.dateStampExif && fileProperties.freeText && rangement_instance.keepFreeText) { + if (timestampFormatted && fileProperties.freeText && rangement_instance.keepFreeText ) { spacer = ' ' } - let newName = '' - + fileProperties.dateStampExif + + /** + * assemblage du schéma de nom + */ + newName += timestampFormatted + spacer + (rangement_instance.keepFreeText ? fileProperties.freeText : '') + tagPlace.trim() - + fileProperties.extension.trim() + + extension if (rangement_instance.replaceUnderscoreWithSpaces) { newName = newName.replace('_', ' ')