split config files

This commit is contained in:
Tykayn 2023-07-19 10:04:08 +02:00 committed by tykayn
parent e7f4ded272
commit e41eaa0966
10 changed files with 119 additions and 63 deletions

View File

@ -8,6 +8,9 @@ Ce script s'utilise selon la méthode de rangement détaillée ici:
https://www.cipherbliss.com/organiser-ses-fichiers-avec-des-tags-avec-filetags https://www.cipherbliss.com/organiser-ses-fichiers-avec-des-tags-avec-filetags
mais ce n'est pas encore prêt à être utilisé en production. mais ce n'est pas encore prêt à être utilisé en production.
# mise en place
utiliser le setup pour mettre en place l'architecture de dossiers de rangement. Différentes questions vont vous être posées afin de personnaliser les dossiers et vérifier l'intégrité.
# lancement de renommage # lancement de renommage
`devine mon_fichier.jpg mon_autre_fichier.pdf` `devine mon_fichier.jpg mon_autre_fichier.pdf`

40
conf/configs.js Normal file
View File

@ -0,0 +1,40 @@
import mainTemplates from './mainTemplates.mjs'
import constants from './folders.js'
/**
* configuration générale à importer dans les utilitaires
*/
class config_rangement {
log_level = 'info' // 'debug' | 'warn' |'info'
version = '1.0.0'
iso_date_format = 'yyyy-MM-DDTHH.mm.ss' // target format for dates in file names
tagSeparator = ' '
tagSectionSeparator = '--'
keepFreeText = true
keepTags = true
replaceUnderscoreWithSpaces = true
renameFolders = false
enableTestsLocally = false
reportStatistics = false
constants = constants
base_archive_folder = constants.base_archive_folder
templates = mainTemplates;
/**
* override config if we want
* @param overridingConfig
*/
constructor (overridingConfig) {
console.log('overridingConfig', overridingConfig)
let keys = Object.keys(overridingConfig)
let self = this;
keys.forEach(elem=>{
if(self[key]){
self[key] = elem
}
})
}
}
const rangement_instance = new config_rangement({});
export default rangement_instance

22
conf/folders.js Normal file
View File

@ -0,0 +1,22 @@
/**
* constantes de dossier à utiliser pour la mise en place de l'architecture et la config
*/
const base_archive_folder = '/home/poule/encrypted/stockage-syncable/'
const syncronized_folder = '~/Nextcloud/'
const folders = {
base_archive_folder,
photos_sub_folder: base_archive_folder + 'photos/',
photos_sorting_base_sub_folder: base_archive_folder + 'photos/a_dispatcher/',
bazar_sub_folder: base_archive_folder + 'BAZAR/',
gopro_capture_folder: base_archive_folder + 'photos/gopro/bazar/',
panoramax_captures_folder: base_archive_folder + 'photos/imagerie kartaview carto tel/open camera/',
syncronized_folder,
workflow_folder_secrets: syncronized_folder + '/ressources/workflow_nextcloud',
workflow_folder_public: syncronized_folder + '/ressources/workflow_nextcloud/public_workflow',
syncronized_phone_inbox: syncronized_folder + 'InstantUpload',
orgmode_folder: syncronized_folder + 'textes/orgmode',
}
export default folders

46
conf/mainTemplates.mjs Normal file
View File

@ -0,0 +1,46 @@
import constants from './folders.js'
export default {
'downloaded_pic': {
'example': 'FyB8cZnWIAc21rw.jpg',
'pattern': /^\-\w{15}\.jpg/,
'auto_tag':'',
'auto_sort_folder': constants.bazar_sub_folder
},
'telegram_pic': {
'example': '-4900281569878475578_1109.jpg',
'pattern': /^\-\d{19}_\d{4}/,
'auto_tag':'',
'auto_sort_folder': constants.bazar_sub_folder
},
'open_camera_default': {
'example': 'IMG_20230617_092120_3.jpg',
'pattern': /^IMG_\d{8}/i,
'auto_tag':'',
'auto_sort_folder': constants.panoramax_captures_folder
},
'open_camera_custom': {
'example': 'IMG_OC_20230617_092120_3.jpg',
'pattern': /^IMG_OC_\d{8}/i,
'auto_tag':'',
'auto_sort_folder': constants.panoramax_captures_folder
},
'screenshot': {
'example': 'Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png',
'pattern': /^Screenshot/i,
'auto_tag':'screenshots',
'auto_sort_folder': 'photos/captures écran screenshots'
},
'gopro_front': {
'example': 'GF010041.jpg',
'pattern': /^GP?F\d+\.jpg/i,
'auto_tag':'gopro-front gopro',
'auto_sort_folder': constants.gopro_capture_folder
},
'gopro_back': {
'example': 'GB010041.jpg',
'pattern': /^GP?B\d+\.jpg/i,
'auto_tag':'gopro-back gopro',
'auto_sort_folder': constants.gopro_capture_folder
},
}

View File

@ -1,57 +0,0 @@
class config_rangement {
log_level = 'info' // 'debug' | 'warn' |'info'
version = '1.0.0'
iso_date_format = 'yyyy-MM-DDTHH.mm.ss' // target format for dates in file names
tagSeparator = ' '
tagSectionSeparator = '--'
keepFreeText = true
keepTags = true
replaceUnderscoreWithSpaces = true
renameFolders = false
enableTestsLocally = false
reportStatistics = false
base_archive_folder = '/home/poule/encrypted/stockage-syncable/'
photos_sub_folder = this.base_archive_folder + 'photos/'
photos_sorting_base_sub_folder = this.base_archive_folder + 'photos/a_dispatcher/'
bazar_sub_folder = this.base_archive_folder + 'BAZAR/'
panoramax_captures_folder = 'photos/imagerie kartaview carto tel/open camera/'
templates = {
// example FyB8cZnWIAc21rw.jpg
'downloaded_pic': {
'pattern': /^\-\w{15}\.jpg/,
'auto_sort_folder': this.bazar_sub_folder
},
// example -4900281569878475578_1109.jpg
'telegram_pic': {
'pattern': /^\-\d{19}_\d{4}/,
'auto_sort_folder': this.bazar_sub_folder
},
// example IMG_20230617_092120_3.jpg
'open_camera_default': {
'pattern': /^IMG_\d{8}/i,
'auto_sort_folder': this.panoramax_captures_folder
},
// example IMG_OC_20230617_092120_3.jpg
'open_camera_custom': {
'pattern': /^IMG_OC_\d{8}/i,
'auto_sort_folder': this.panoramax_captures_folder
},
// example "Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png"
'screenshot': {
'pattern': /^Screenshot/i,
'auto_sort_folder': 'photos/captures écran screenshots'
},
}
;
}
const rangement_instance = new config_rangement();
export const tagSeparator = rangement_instance.tagSeparator
export const tagSectionSeparator = rangement_instance.tagSectionSeparator
export const enableTestsLocally = rangement_instance.enableTestsLocally
export const reportStatistics = rangement_instance.reportStatistics
export default rangement_instance

View File

@ -2,8 +2,8 @@
handles creation of global hierarchy of folders from config file handles creation of global hierarchy of folders from config file
*/ */
import config_rangement from './configs.mjs' import config_rangement from './conf/configs.js'
let my_conf = new config_rangement() let my_conf = new config_rangement({})
console.log('config', my_conf.version) console.log('config', my_conf.version)

View File

@ -1,7 +1,7 @@
/** /**
* la classe qui repère des patterns * la classe qui repère des patterns
*/ */
import rangement_instance from './configs.mjs' import rangement_instance from './conf/configs'
import exifr from 'exifr' import exifr from 'exifr'
import moment from 'moment' import moment from 'moment'
import log from 'loglevel' import log from 'loglevel'

View File

@ -13,7 +13,7 @@ import path from 'node:path'
/** --------------------- /** ---------------------
custom utilities and configuration custom utilities and configuration
--------------------- */ --------------------- */
import rangement_instance from './configs.mjs' import rangement_instance from './conf/configs.js'
import { import {
TestFindFormattedDate, TestFindFormattedDate,
TestScreenShotIsFoundAndRenamed, TestScreenShotIsFoundAndRenamed,

View File

@ -3,6 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"description": "sorting utilities and file tagging using PIM methodology of Karl Voit", "description": "sorting utilities and file tagging using PIM methodology of Karl Voit",
"main": "index.mjs", "main": "index.mjs",
"type": "module",
"scripts": { "scripts": {
"start": "node index.mjs", "start": "node index.mjs",
"devine": "node index.mjs", "devine": "node index.mjs",

View File

@ -2,7 +2,7 @@
création de la config création de la config
*/ */
// import i18next from 'i18next' // import i18next from 'i18next'
import config_rangement from "./configs"; import config_rangement from "./conf/configs.js";
const { stdin, stdout } = process; const { stdin, stdout } = process;
@ -24,7 +24,8 @@ async function main() {
// const age = await prompt("What's your age? "); // const age = await prompt("What's your age? ");
// const email = await prompt("What's your email address? "); // const email = await prompt("What's your email address? ");
// const user = { name, age, email }; // const user = { name, age, email };
console.log(name); console.log('le dossier de base des archives est : ',name);
stdin.pause(); stdin.pause();
} catch(error) { } catch(error) {
console.log("There's an error!"); console.log("There's an error!");