merge with main
This commit is contained in:
commit
6f7f2252ac
17
README.md
17
README.md
@ -25,11 +25,22 @@ mais ce n'est pas encore prêt à être utilisé en production.
|
|||||||
|
|
||||||
"npm start" gives you a demo of what Rangement can do, but this is not a production ready package yet.
|
"npm start" gives you a demo of what Rangement can do, but this is not a production ready package yet.
|
||||||
|
|
||||||
|
# done
|
||||||
|
|
||||||
|
* Handle verbosity levels in logs
|
||||||
|
- log.trace(msg)
|
||||||
|
- log.debug(msg)
|
||||||
|
- log.info(msg)
|
||||||
|
- log.warn(msg)
|
||||||
|
- log.error(msg)
|
||||||
|
|
||||||
|
|
||||||
# Roadmap
|
# Roadmap
|
||||||
|
* Internationalisation of console texts
|
||||||
* Proper testing
|
* Proper testing
|
||||||
* Handle verbosity levels
|
* Template configuration for auto dispatching of files after rename
|
||||||
* Handle a configuration file
|
* Handle a configuration file
|
||||||
* create config file if needed
|
- * create config file if needed
|
||||||
* batch rename like the python pip script "guessfilename"
|
* batch rename like the python pip script "guessfilename"
|
||||||
* revert renaming actions
|
* revert renaming actions
|
||||||
* Log renaming actions
|
- * Log renaming actions
|
||||||
|
64
configs.mjs
64
configs.mjs
@ -1,45 +1,57 @@
|
|||||||
|
class config_rangement {
|
||||||
export default class config_rangement{
|
log_level = 'info' // 'debug' | 'warn' |'info'
|
||||||
log_level ='debug' // [ 'debug' 'none']
|
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
tagSeparator = '1.0.0'
|
iso_date_format = 'yyyy-MM-DDTHH.mm.ss' // target format for dates in file names
|
||||||
tagSectionSeparator = '1.0.0'
|
tagSeparator = ' '
|
||||||
enableTestsLocally= false
|
tagSectionSeparator = '--'
|
||||||
reportStatistics= false
|
keepFreeText = true
|
||||||
base_archive_folder= '/home/poule/encrypted/stockage-syncable/'
|
keepTags = true
|
||||||
photos_sub_folder= 'photos'
|
replaceUnderscoreWithSpaces = true
|
||||||
photos_sorting_base_sub_folder= 'photos/a_dispatcher'
|
renameFolders = false
|
||||||
bazar_sub_folder= 'BAZAR'
|
enableTestsLocally = false
|
||||||
panoramax_captures_folder= 'photos/imagerie kartaview carto tel/open camera'
|
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 = {
|
templates = {
|
||||||
// example FyB8cZnWIAc21rw.jpg
|
// example FyB8cZnWIAc21rw.jpg
|
||||||
'downloaded_pic': {
|
'downloaded_pic': {
|
||||||
'pattern' : /^\-\w{15}\.jpg/,
|
'pattern': /^\-\w{15}\.jpg/,
|
||||||
'auto_sort_folder' : this.bazar_sub_folder
|
'auto_sort_folder': this.bazar_sub_folder
|
||||||
},
|
},
|
||||||
// example -4900281569878475578_1109.jpg
|
// example -4900281569878475578_1109.jpg
|
||||||
'telegram_pic': {
|
'telegram_pic': {
|
||||||
'pattern' : /^\-\d{19}_\d{4}/,
|
'pattern': /^\-\d{19}_\d{4}/,
|
||||||
'auto_sort_folder' : ''
|
'auto_sort_folder': this.bazar_sub_folder
|
||||||
},
|
},
|
||||||
// example IMG_20230617_092120_3.jpg
|
// example IMG_20230617_092120_3.jpg
|
||||||
'open_camera_default': {
|
'open_camera_default': {
|
||||||
'pattern' : /^IMG_\d{8}/i,
|
'pattern': /^IMG_\d{8}/i,
|
||||||
'auto_sort_folder' : this.panoramax_captures_folder
|
'auto_sort_folder': this.panoramax_captures_folder
|
||||||
},
|
},
|
||||||
// example IMG_OC_20230617_092120_3.jpg
|
// example IMG_OC_20230617_092120_3.jpg
|
||||||
'open_camera_custom': {
|
'open_camera_custom': {
|
||||||
'pattern' : /^IMG_OC_\d{8}/i,
|
'pattern': /^IMG_OC_\d{8}/i,
|
||||||
'auto_sort_folder' : this.panoramax_captures_folder
|
'auto_sort_folder': this.panoramax_captures_folder
|
||||||
},
|
},
|
||||||
// example "Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png"
|
// example "Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png"
|
||||||
'screenshot': {
|
'screenshot': {
|
||||||
'pattern' : /^Screenshot/i,
|
'pattern': /^Screenshot/i,
|
||||||
'auto_sort_folder': 'photos/captures écran screenshots'
|
'auto_sort_folder': 'photos/captures écran screenshots'
|
||||||
} ,
|
},
|
||||||
}
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
export const tagSeparator = ' '
|
|
||||||
export const tagSectionSeparator = '--'
|
const rangement_instance = new config_rangement();
|
||||||
export const enableTestsLocally = false
|
|
||||||
export const reportStatistics = false
|
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
|
||||||
|
|
||||||
|
78
finder.mjs
78
finder.mjs
@ -1,11 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* la classe qui repère des patterns
|
* la classe qui repère des patterns
|
||||||
*/
|
*/
|
||||||
import { tagSectionSeparator, tagSeparator } from './configs.mjs'
|
import rangement_instance from './configs.mjs'
|
||||||
import exifr from 'exifr'
|
import exifr from 'exifr'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import log from 'log_level'
|
import log from 'loglevel'
|
||||||
|
|
||||||
|
log.setLevel(rangement_instance.log_level)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds patterns for file name
|
* finds patterns for file name
|
||||||
@ -17,7 +18,7 @@ export default class finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static reportStatistics () {
|
static reportStatistics () {
|
||||||
console.log('statistics',
|
log.info('statistics',
|
||||||
this.statistics)
|
this.statistics)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ export default class finder {
|
|||||||
|
|
||||||
static findFormattedDate (filepath) {
|
static findFormattedDate (filepath) {
|
||||||
let match = filepath.match(/\d{4}-\d{2}-\d{2}T\d{2}\.\d{2}\.\d{2}/ig)
|
let match = filepath.match(/\d{4}-\d{2}-\d{2}T\d{2}\.\d{2}\.\d{2}/ig)
|
||||||
log.debug('match findFormattedDate', match)
|
log.debug(' finder - match findFormattedDate', match)
|
||||||
let result = ''
|
let result = ''
|
||||||
if (match && match[0]) {
|
if (match && match[0]) {
|
||||||
result = match[0]
|
result = match[0]
|
||||||
@ -36,11 +37,8 @@ export default class finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static findFileExtension (inputString) {
|
static findFileExtension (inputString) {
|
||||||
if(!inputString){
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
let result = inputString.match(/\.\w{3,4}$/i)
|
let result = inputString.match(/\.\w{3,4}$/i)
|
||||||
return result.shift()
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,10 +48,10 @@ export default class finder {
|
|||||||
*/
|
*/
|
||||||
static findFileNameFreeTextPart (fileName) {
|
static findFileNameFreeTextPart (fileName) {
|
||||||
fileName = fileName.replace(this.findFileExtension(fileName), '')
|
fileName = fileName.replace(this.findFileExtension(fileName), '')
|
||||||
let boom = fileName.split(tagSectionSeparator)
|
let boom = fileName.split(rangement_instance.tagSectionSeparator)
|
||||||
if (boom.length) {
|
if (boom.length) {
|
||||||
let freeTextPart = boom[0].trim()
|
let freeTextPart = boom[0].trim()
|
||||||
console.log('freeTextPart', freeTextPart)
|
log.debug(' finder - freeTextPart', freeTextPart)
|
||||||
return freeTextPart
|
return freeTextPart
|
||||||
}
|
}
|
||||||
return fileName.trim()
|
return fileName.trim()
|
||||||
@ -72,24 +70,24 @@ export default class finder {
|
|||||||
if (extensionFile) {
|
if (extensionFile) {
|
||||||
extensionFile = extensionFile[0]
|
extensionFile = extensionFile[0]
|
||||||
} else {
|
} else {
|
||||||
console.log('no extensionFile', extensionFile, inputString)
|
log.debug(' finder - no extensionFile', extensionFile, inputString)
|
||||||
extensionFile = ''
|
extensionFile = ''
|
||||||
}
|
}
|
||||||
inputString = inputString.replace(extensionFile, '')
|
inputString = inputString.replace(extensionFile, '')
|
||||||
|
|
||||||
log.debug('extensionFile', extensionFile)
|
log.debug(' finder - extensionFile', extensionFile)
|
||||||
if (inputString.includes(tagSectionSeparator)) {
|
if (inputString.includes(rangement_instance.tagSectionSeparator)) {
|
||||||
log.debug('inputString', inputString)
|
log.debug(' finder - inputString', inputString)
|
||||||
if (inputString.length) {
|
if (inputString.length) {
|
||||||
|
|
||||||
let boom = inputString.split(tagSectionSeparator)
|
let boom = inputString.split(rangement_instance.tagSectionSeparator)
|
||||||
log.debug('boom', boom)
|
log.debug(' finder - boom', boom)
|
||||||
if (boom.length) {
|
if (boom.length) {
|
||||||
let fileSectionsName = boom.splice(tagSeparator)
|
let fileSectionsName = boom.splice(rangement_instance.tagSeparator)
|
||||||
listOfTags = [...fileSectionsName[1].trim().split(tagSeparator)]
|
listOfTags = [...fileSectionsName[1].trim().split(rangement_instance.tagSeparator)]
|
||||||
log.debug('listOfTags', listOfTags)
|
log.debug(' finder - listOfTags', listOfTags)
|
||||||
} else {
|
} else {
|
||||||
console.log('no boom', boom)
|
log.debug(' finder - no boom', boom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,15 +108,15 @@ export default class finder {
|
|||||||
static searchAndRenameScreenshots (fileName) {
|
static searchAndRenameScreenshots (fileName) {
|
||||||
if (finder.findScreenshot(fileName)) {
|
if (finder.findScreenshot(fileName)) {
|
||||||
let tags = this.findTagSectionInString(fileName)
|
let tags = this.findTagSectionInString(fileName)
|
||||||
console.log('tags', tags)
|
log.debug(' finder - tags', tags)
|
||||||
if (!tags.includes('screenshot')) {
|
if (!tags.includes('screenshot')) {
|
||||||
|
|
||||||
fileName = this.addTagInFileName('screenshot', fileName)
|
fileName = this.addTagInFileName('screenshot', fileName)
|
||||||
fileName = this.searchAndReplaceInFileName('Screenshot', '', fileName)
|
fileName = this.searchAndReplaceInFileName('Screenshot', '', fileName)
|
||||||
console.log('screenShotMockFileName:', fileName)
|
log.debug(' finder - screenShotMockFileName:', fileName)
|
||||||
return this.cleanSpaces(fileName)
|
return this.cleanSpaces(fileName)
|
||||||
}
|
}
|
||||||
console.log('is a screenshot, remove screenshot in name, and add tag screenshot')
|
log.debug(' finder - is a screenshot, remove screenshot in name, and add tag screenshot')
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -132,7 +130,7 @@ export default class finder {
|
|||||||
tags.push(tagName)
|
tags.push(tagName)
|
||||||
let uniqueArray = [...new Set(tags)]
|
let uniqueArray = [...new Set(tags)]
|
||||||
|
|
||||||
let newFileName = firstPart + ' ' + tagSectionSeparator + ' ' + tags.join(tagSeparator)
|
let newFileName = firstPart + ' ' + rangement_instance.tagSectionSeparator + ' ' + tags.join(rangement_instance.tagSeparator)
|
||||||
newFileName = newFileName.replace(/ {*}/, '') + this.findFileExtension(fileName)
|
newFileName = newFileName.replace(/ {*}/, '') + this.findFileExtension(fileName)
|
||||||
return this.cleanSpaces(newFileName)
|
return this.cleanSpaces(newFileName)
|
||||||
}
|
}
|
||||||
@ -168,17 +166,17 @@ export default class finder {
|
|||||||
|
|
||||||
let moments = []
|
let moments = []
|
||||||
|
|
||||||
log.debug('exif data : ', exifData) // Do something with your data!
|
log.debug(' finder - exif data : ', exifData) // Do something with your data!
|
||||||
if (exifData.DateTimeOriginal) {
|
if (exifData.DateTimeOriginal) {
|
||||||
log.debug('image créée le : DateTimeOriginal : ', exifData.DateTimeOriginal) // Do something with your data!
|
log.debug(' finder - image créée le : DateTimeOriginal : ', exifData.DateTimeOriginal) // Do something with your data!
|
||||||
moments.push(exifData.DateTimeOriginal)
|
moments.push(exifData.DateTimeOriginal)
|
||||||
}
|
}
|
||||||
if (exifData.ModificationDateTime) {
|
if (exifData.ModificationDateTime) {
|
||||||
log.debug('image créée le : ModificationDateTime : ', exifData.ModificationDateTime) // Do something with your data!
|
log.debug(' finder - image créée le : ModificationDateTime : ', exifData.ModificationDateTime) // Do something with your data!
|
||||||
moments.push(exifData.ModificationDateTime)
|
moments.push(exifData.ModificationDateTime)
|
||||||
}
|
}
|
||||||
if (exifData.ModifyDate) {
|
if (exifData.ModifyDate) {
|
||||||
log.debug('image créée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
log.debug(' finder - image créée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
||||||
moments.push(exifData.ModifyDate)
|
moments.push(exifData.ModifyDate)
|
||||||
}
|
}
|
||||||
if (exifData.FileAccessDateTime) {
|
if (exifData.FileAccessDateTime) {
|
||||||
@ -188,11 +186,11 @@ export default class finder {
|
|||||||
moments.push(exifData.FileInodeChangeDateTime)
|
moments.push(exifData.FileInodeChangeDateTime)
|
||||||
}
|
}
|
||||||
if (exifData.FileModificationDateTime) {
|
if (exifData.FileModificationDateTime) {
|
||||||
log.debug('image créée le : FileModificationDateTime : ', exifData.FileModificationDateTime) // Do something with your data!
|
log.debug(' finder - image créée le : FileModificationDateTime : ', exifData.FileModificationDateTime) // Do something with your data!
|
||||||
moments.push(exifData.FileModificationDateTime)
|
moments.push(exifData.FileModificationDateTime)
|
||||||
}
|
}
|
||||||
if (exifData.CreateDate) {
|
if (exifData.CreateDate) {
|
||||||
log.debug('image créée le : CreateDate : ', exifData.CreateDate) // Do something with your data!
|
log.debug(' finder - image créée le : CreateDate : ', exifData.CreateDate) // Do something with your data!
|
||||||
moments.push(exifData.CreateDate)
|
moments.push(exifData.CreateDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,27 +200,31 @@ export default class finder {
|
|||||||
})
|
})
|
||||||
let minDate = moment.min(moments)
|
let minDate = moment.min(moments)
|
||||||
|
|
||||||
log.debug('minDate :::::::::', minDate)
|
log.debug(' finder - minDate :::::::::', minDate)
|
||||||
console.log('minDate :::::::::', minDate.format('yyyy-MM-DDTHH:mm:ss'))
|
log.info(' finder - minDate :::::::::', minDate.format(rangement_instance.iso_date_format))
|
||||||
|
|
||||||
return minDate.format('yyyy-MM-DDTHH:mm:ss')
|
return minDate.format(rangement_instance.iso_date_format)
|
||||||
} else {
|
} else {
|
||||||
console.log('pas de exif data')
|
log.debug(' finder - pas de exif data')
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static findTemplateInFileName (fileName) {
|
||||||
|
// test all templates from configuration
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* examine plusieurs propriétés exif de date et retourne la plus ancienne
|
* examine plusieurs propriétés exif de date et retourne la plus ancienne
|
||||||
* @param filepath
|
* @param filepath
|
||||||
*/
|
*/
|
||||||
static async findExifCreationDate (filepath) {
|
static async findExifCreationDate (filepath) {
|
||||||
|
|
||||||
console.log('filepath', filepath)
|
log.debug(' finder - filepath', filepath)
|
||||||
let dateAlreadyInFileName = finder.findFormattedDate(filepath)
|
let dateAlreadyInFileName = finder.findFormattedDate(filepath)
|
||||||
if (dateAlreadyInFileName) {
|
if (dateAlreadyInFileName) {
|
||||||
|
|
||||||
console.log('------ dateAlreadyInFileName', dateAlreadyInFileName)
|
log.debug(' finder - ------ dateAlreadyInFileName', dateAlreadyInFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await exifr.parse(filepath)
|
return await exifr.parse(filepath)
|
||||||
@ -234,8 +236,8 @@ export default class finder {
|
|||||||
let fileName = folders.pop()
|
let fileName = folders.pop()
|
||||||
folders = filePath.replace(fileName, '')
|
folders = filePath.replace(fileName, '')
|
||||||
|
|
||||||
console.log('\n - folders', folders)
|
log.debug(' finder - \n - folders', folders)
|
||||||
console.log(' - fileName', fileName, '\n')
|
log.debug(' finder - - fileName', fileName, '\n')
|
||||||
return [folders, fileName]
|
return [folders, fileName]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
204
index.mjs
204
index.mjs
@ -8,10 +8,12 @@
|
|||||||
--------------------- */
|
--------------------- */
|
||||||
import fs from 'node-fs'
|
import fs from 'node-fs'
|
||||||
import minimist from 'minimist'
|
import minimist from 'minimist'
|
||||||
|
import log from 'loglevel';
|
||||||
|
import path from "node:path";
|
||||||
/** ---------------------
|
/** ---------------------
|
||||||
custom utilities and configuration
|
custom utilities and configuration
|
||||||
--------------------- */
|
--------------------- */
|
||||||
import { enableTestsLocally, reportStatistics, tagSectionSeparator, tagSeparator } from './configs.mjs'
|
import rangement_instance from './configs.mjs'
|
||||||
import {
|
import {
|
||||||
TestFindFormattedDate,
|
TestFindFormattedDate,
|
||||||
TestScreenShotIsFoundAndRenamed,
|
TestScreenShotIsFoundAndRenamed,
|
||||||
@ -19,121 +21,219 @@ import {
|
|||||||
} from './testFunctions.mjs'
|
} from './testFunctions.mjs'
|
||||||
import finder from './finder.mjs'
|
import finder from './finder.mjs'
|
||||||
|
|
||||||
let mini_arguments
|
import exiftool from "node-exiftool";
|
||||||
console.log(' ')
|
|
||||||
|
|
||||||
function parseArguments () {
|
let mini_arguments
|
||||||
|
|
||||||
|
log.setLevel(rangement_instance.log_level)
|
||||||
|
log.info(' ')
|
||||||
|
|
||||||
|
function parseArguments() {
|
||||||
mini_arguments = minimist(process.argv.slice(2))
|
mini_arguments = minimist(process.argv.slice(2))
|
||||||
console.log('arguments', mini_arguments)
|
log.debug('arguments', mini_arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
parseArguments()
|
function addOriginalFileNameIfMissing(originalFileName, fileMixedNewName) {
|
||||||
|
|
||||||
function renameFile (originalFileName, fileMixedNewName) {
|
// const ep = new exiftool.ExiftoolProcess()
|
||||||
|
//
|
||||||
|
// ep
|
||||||
|
// .open(fileMixedNewName)
|
||||||
|
// .then(() => ep.writeMetadata(fileMixedNewName, {
|
||||||
|
// 'OriginalFileName+': originalFileName,
|
||||||
|
// }))
|
||||||
|
// .then(console.log, console.error)
|
||||||
|
// .then(() => ep.close())
|
||||||
|
// .catch(console.error)
|
||||||
|
}
|
||||||
|
|
||||||
|
function renameFile(originalFileName, fileMixedNewName) {
|
||||||
fs.rename(originalFileName, fileMixedNewName, function (err) {
|
fs.rename(originalFileName, fileMixedNewName, function (err) {
|
||||||
console.log('name changed', fileMixedNewName)
|
log.info('name changed', fileMixedNewName)
|
||||||
if (err) console.log('rename ERROR: ' + err)
|
if (err) {
|
||||||
|
log.info('rename ERROR: ' + err)
|
||||||
|
} else {
|
||||||
|
// otherRenames.push(originalFileName)
|
||||||
|
otherRenames.push(fileMixedNewName)
|
||||||
|
|
||||||
|
addOriginalFileNameIfMissing(originalFileName, fileMixedNewName)
|
||||||
|
// rangement_instance.statistics['filesModified']++
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendFileName (fileProperties, newText) {
|
function appendFileName(fileProperties, newText) {
|
||||||
fileProperties.freeText = finder.cleanSpaces(fileProperties.freeText + ' ' + newText)
|
fileProperties.freeText = finder.cleanSpaces(fileProperties.freeText + ' ' + newText)
|
||||||
return fileProperties
|
return fileProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
function prependFileName (fileProperties, newText) {
|
function prependFileName(fileProperties, newText) {
|
||||||
fileProperties.freeText = finder.cleanSpaces(newText + ' ' + fileProperties.freeText)
|
fileProperties.freeText = finder.cleanSpaces(newText + ' ' + fileProperties.freeText)
|
||||||
return fileProperties
|
return fileProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeFileNameFromProperties (fileProperties) {
|
function makeFileNameFromProperties(fileProperties) {
|
||||||
|
|
||||||
let tagPlace = ''
|
let tagPlace = ''
|
||||||
if (fileProperties.tags.length) {
|
log.info('fileProperties.tags',fileProperties.tags)
|
||||||
tagPlace = ' ' + tagSectionSeparator + ' '
|
if (fileProperties.tags.length && rangement_instance.keepTags) {
|
||||||
|
tagPlace = ' ' + rangement_instance.tagSectionSeparator + ' '+ fileProperties.tags.join(rangement_instance.tagSeparator)
|
||||||
}
|
}
|
||||||
// return finder.cleanSpaces(fileProperties.dateStamp + ' ' + fileProperties.freeText + tagPlace + fileProperties.tags.join(tagSeparator) + fileProperties.extension).replace(+' ' + tagSectionSeparator + ' ' + '.', '.')
|
console.log('fileProperties.dateStampExif', fileProperties.dateStampExif)
|
||||||
return '' + fileProperties.dateStampExif + ' ' + fileProperties.freeText + tagPlace + fileProperties.tags.join(tagSeparator) + fileProperties.extension
|
let newName = ''
|
||||||
|
+ fileProperties.dateStampExif
|
||||||
|
+ ' '
|
||||||
|
+ (rangement_instance.keepFreeText? fileProperties.freeText : '')
|
||||||
|
+ tagPlace
|
||||||
|
+ fileProperties.extension;
|
||||||
|
|
||||||
|
if(rangement_instance.replaceUnderscoreWithSpaces){
|
||||||
|
newName = newName.replace('_', ' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
newName = newName.replace(' ', '')
|
||||||
|
|
||||||
|
return newName
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldWeChangeName (structureForFile) {
|
let otherRenames = [];
|
||||||
console.log(' ______ allez hop fini la recherche on fait un nouveau nom')
|
|
||||||
console.log('structureForFile', structureForFile)
|
|
||||||
let newName = makeFileNameFromProperties(structureForFile)
|
|
||||||
if (structureForFile.fileNameOriginal !== newName) {
|
|
||||||
|
|
||||||
console.log('\n ancien nom :', structureForFile.fileNameOriginal)
|
function shouldWeChangeName(structureForFile) {
|
||||||
// console.log(' nouveau nom:', foundDate +structureForFile.freeText + structureForFile.tags.join(tagSeparator) + structureForFile.extension )
|
log.info(' ______ shouldWeChangeName ', structureForFile.fileNameOriginal)
|
||||||
console.log(' nouveau nom:', newName)
|
let newName = makeFileNameFromProperties(structureForFile)
|
||||||
if (!mini_arguments.dryRun) {
|
log.debug('newName', newName)
|
||||||
|
if (structureForFile.fileNameOriginal !== newName && !otherRenames.includes(newName)) {
|
||||||
|
|
||||||
|
log.info('\n ancien nom :', structureForFile.fileNameOriginal)
|
||||||
|
|
||||||
|
log.info(' nouveau nom:', newName)
|
||||||
|
if (!mini_arguments['dry-run']) {
|
||||||
renameFile(structureForFile.fullPath, structureForFile.folderPath + newName)
|
renameFile(structureForFile.fullPath, structureForFile.folderPath + newName)
|
||||||
} else {
|
} else {
|
||||||
console.log('no renaming for real, this is a dry run')
|
log.info('no renaming for real, this is a dry run')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(' rien à changer')
|
log.info(' rien à changer')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function guessFileNameOnAllFilesFromArguments () {
|
/**
|
||||||
|
* guess file name on one file which is not a directory
|
||||||
|
* @param fullPath
|
||||||
|
*/
|
||||||
|
function guessFileNameOnOnefile(fullPath) {
|
||||||
|
|
||||||
// parcourir les dossiers
|
log.info('go guess file name on file: ', fullPath )
|
||||||
// parcourir les fichiers
|
fs.stat(fullPath, (err, stats) => {
|
||||||
|
|
||||||
console.log('liste des fichiers', mini_arguments._)
|
if (err) {
|
||||||
let fileList = mini_arguments._
|
log.error('échec fichier', err)
|
||||||
|
log.error('ce fichier n existe pas: ', fullPath)
|
||||||
fileList.forEach(fullPath => {
|
return;
|
||||||
|
} else {
|
||||||
|
|
||||||
let structureForFile = finder.destructurateFileName(fullPath)
|
let structureForFile = finder.destructurateFileName(fullPath)
|
||||||
|
|
||||||
// examiner les infos exif de chaque fichier pour proposer un nouveau nom
|
// examiner les infos exif de chaque fichier pour proposer un nouveau nom
|
||||||
if (!structureForFile.dateStampInFileNameOriginal) {
|
if (!structureForFile.dateStampInFileNameOriginal) {
|
||||||
console.log(' le nom de fichier ne contient pas de date formatée au début')
|
log.info(' le nom de fichier "'+structureForFile.freeText +'" ne contient pas de date formatée au début')
|
||||||
|
|
||||||
finder.findExifCreationDate(structureForFile.fullPath)
|
finder.findExifCreationDate(structureForFile.fullPath)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(' ... chercher la date de création')
|
log.info(' ... chercher la date de création : "'+structureForFile.freeText +'"')
|
||||||
let foundDate = finder.findEarliestDateInExifData(data)
|
let foundDate = finder.findEarliestDateInExifData(data)
|
||||||
|
|
||||||
console.log(' =>>>>>>> foundDate : ', foundDate)
|
log.info(' =>>>>>>> foundDate : ', foundDate)
|
||||||
if (foundDate) {
|
if (foundDate) {
|
||||||
|
|
||||||
// finder.findEarliestDateInExifData(fullPath).then(response => {
|
|
||||||
// console.log(' ... trouvée')
|
|
||||||
// if (response) {
|
|
||||||
structureForFile.dateStampExif = foundDate
|
structureForFile.dateStampExif = foundDate
|
||||||
|
|
||||||
shouldWeChangeName(structureForFile)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log('pas de date trouvée dans le nom')
|
log.info('pas de date trouvée dans le nom')
|
||||||
}
|
}
|
||||||
|
shouldWeChangeName(structureForFile)
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
(error) => {
|
(error) => {
|
||||||
console.log('/////////// Error in reading exif of file: ' + error.message)
|
log.warn('/////////// Error in reading exif of file: ' + error.message)
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let expandedFileList = []
|
||||||
|
let cwd = path.dirname(process.cwd()) + '/' + path.basename(process.cwd());
|
||||||
|
console.log('cwd', cwd)
|
||||||
|
|
||||||
|
function guessFileNameOnAllFilesFromArguments() {
|
||||||
|
|
||||||
|
|
||||||
|
// parcourir les fichiers
|
||||||
|
log.debug('liste des fichiers', mini_arguments._)
|
||||||
|
let fileList = mini_arguments._
|
||||||
|
|
||||||
|
|
||||||
|
// test file exists
|
||||||
|
fileList.forEach(fullPath => {
|
||||||
|
// parcourir les dossiers
|
||||||
|
isFolderOrFile(`${fullPath}`)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log.info('expanded file list :', expandedFileList)
|
||||||
|
expandedFileList.forEach(filePath => guessFileNameOnOnefile(filePath))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readSubdirectories(baseDir) {
|
||||||
|
const newGlob = baseDir;
|
||||||
|
fs.readdir(baseDir, (err, files) => {
|
||||||
|
if (err) throw err;
|
||||||
|
|
||||||
|
console.log('readSubdirectories - files', files)
|
||||||
|
files.forEach((subDirOrFile) => {
|
||||||
|
const newFullPath = cwd +'/'+ subDirOrFile;
|
||||||
|
|
||||||
|
if (fs.existsSync(newFullPath)) {
|
||||||
|
const s = fs.statSync(newFullPath);
|
||||||
|
|
||||||
|
if (s.isFile()) {
|
||||||
|
expandedFileList.push(cwd+'/'+subDirOrFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFolderOrFile(fileName) {
|
||||||
|
// const stat = fs.statSync(cwd + '/' + fileName);
|
||||||
|
const stat = fs.statSync( fileName);
|
||||||
|
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
let fileList = readSubdirectories(fileName);
|
||||||
|
console.log('fileList in directory ',fileName, '\n', fileList)
|
||||||
|
if (fileList) {
|
||||||
|
expandedFileList.push(...fileList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (stat.isFile()) {
|
||||||
|
expandedFileList.push(cwd + '/' + fileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parseArguments()
|
||||||
|
|
||||||
guessFileNameOnAllFilesFromArguments()
|
guessFileNameOnAllFilesFromArguments()
|
||||||
|
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
if (enableTestsLocally) {
|
if (rangement_instance.enableTestsLocally) {
|
||||||
|
|
||||||
TestTagsAreDetectedInFileName()
|
TestTagsAreDetectedInFileName()
|
||||||
TestFindFormattedDate()
|
TestFindFormattedDate()
|
||||||
TestScreenShotIsFoundAndRenamed()
|
TestScreenShotIsFoundAndRenamed()
|
||||||
}
|
}
|
||||||
if (reportStatistics || mini_arguments.stats) {
|
if (rangement_instance.reportStatistics || mini_arguments.stats) {
|
||||||
finder.reportStatistics()
|
finder.reportStatistics()
|
||||||
}
|
}
|
||||||
|
15
main.test.js
15
main.test.js
@ -1,4 +1,5 @@
|
|||||||
import finder from "./finder.mjs";
|
// import finder from "./finders.mjs";
|
||||||
|
const finders = require('./finders.mjs')
|
||||||
|
|
||||||
describe('rangement file name', () => {
|
describe('rangement file name', () => {
|
||||||
|
|
||||||
@ -6,6 +7,16 @@ describe('rangement file name', () => {
|
|||||||
expect(finder.findFormattedDate('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('2023-06-23T18.36.47');
|
expect(finder.findFormattedDate('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('2023-06-23T18.36.47');
|
||||||
});
|
});
|
||||||
test('detects file extension in file name', () => {
|
test('detects file extension in file name', () => {
|
||||||
expect(finder.findFileExtension('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('.jpg');
|
expect(finder.findFileExtension()('2023-06-23T18.36.47 -- machin bidule.jpg')).toBe('jpg');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
console.log('finders', finder)
|
||||||
|
|
||||||
|
test('adding positive numbers is not zero', () => {
|
||||||
|
for (let a = 1; a < 10; a++) {
|
||||||
|
for (let b = 1; b < 10; b++) {
|
||||||
|
expect(a + b).not.toBe(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
84
package-lock.json
generated
84
package-lock.json
generated
@ -10,8 +10,10 @@
|
|||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"exifr": "^7.1.3",
|
"exifr": "^7.1.3",
|
||||||
|
"i18next": "^23.2.6",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
|
"node-exiftool": "^2.3.0",
|
||||||
"node-fs": "^0.1.7"
|
"node-fs": "^0.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -21,6 +23,7 @@
|
|||||||
"@jest/globals": "^29.5.0",
|
"@jest/globals": "^29.5.0",
|
||||||
"babel-jest": "^29.5.0",
|
"babel-jest": "^29.5.0",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
|
"loglevel": "^1.8.1",
|
||||||
"nodemon": "^2.0.22",
|
"nodemon": "^2.0.22",
|
||||||
"ts-node": "^10.9.1"
|
"ts-node": "^10.9.1"
|
||||||
}
|
}
|
||||||
@ -1798,7 +1801,6 @@
|
|||||||
"version": "7.22.5",
|
"version": "7.22.5",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz",
|
||||||
"integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==",
|
"integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"regenerator-runtime": "^0.13.11"
|
"regenerator-runtime": "^0.13.11"
|
||||||
},
|
},
|
||||||
@ -2741,6 +2743,11 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/catchment": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/catchment/-/catchment-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-6sTXWtTXI+MTHrHVnvZnOM8q2ujbQ+qJF0Mu8NM3jifMBCiZssjol/nBHQqOEiKSZKf1e4+wCrgmTXzWzvZs5w=="
|
||||||
|
},
|
||||||
"node_modules/chalk": {
|
"node_modules/chalk": {
|
||||||
"version": "4.1.2",
|
"version": "4.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||||
@ -3280,6 +3287,28 @@
|
|||||||
"node": ">=10.17.0"
|
"node": ">=10.17.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/i18next": {
|
||||||
|
"version": "23.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/i18next/-/i18next-23.2.6.tgz",
|
||||||
|
"integrity": "sha512-i0P2XBisewaICJ7UQtwymeJj6cXUigM+s8XNIXmWk4oJ8iTok2taCbOTX0ps+u9DFcQ6FWH6xLIU0dLEnMaNbA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://locize.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://locize.com/i18next.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.22.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ignore-by-default": {
|
"node_modules/ignore-by-default": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
|
||||||
@ -4174,6 +4203,19 @@
|
|||||||
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
|
"integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/loglevel": {
|
||||||
|
"version": "1.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.8.1.tgz",
|
||||||
|
"integrity": "sha512-tCRIJM51SHjAayKwC+QAg8hT8vg6z7GSgLJKGvzuPb1Wc+hLzqtuVLxp6/HzSPOozuK+8ErAhy7U/sVzw8Dgfg==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "tidelift",
|
||||||
|
"url": "https://tidelift.com/funding/github/npm/loglevel"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/lru-cache": {
|
"node_modules/lru-cache": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||||
@ -4213,6 +4255,11 @@
|
|||||||
"tmpl": "1.0.5"
|
"tmpl": "1.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/makepromise": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/makepromise/-/makepromise-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-M1q31Q56rlA+gwvmfWj7QFDMIJOuj527fQx/rN3dlzUtsopC9ZjtyekIBW4Fw0HZP6O6Azuw3/Vtk5O59bXz7A=="
|
||||||
|
},
|
||||||
"node_modules/merge-stream": {
|
"node_modules/merge-stream": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
|
||||||
@ -4281,6 +4328,24 @@
|
|||||||
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/node-exiftool": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-exiftool/-/node-exiftool-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-UZd+k07thqXqp/1udsZghAFrjrsYfP8Kg48I9uv02FZAmT1Wasr8aAPMCObnYkJiWoD/V8UrGjiSzgfNQy9zBw==",
|
||||||
|
"dependencies": {
|
||||||
|
"is-stream": "1.1.0",
|
||||||
|
"restream": "1.2.0",
|
||||||
|
"wrote": "0.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-exiftool/node_modules/is-stream": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/node-fs": {
|
"node_modules/node-fs": {
|
||||||
"version": "0.1.7",
|
"version": "0.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/node-fs/-/node-fs-0.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/node-fs/-/node-fs-0.1.7.tgz",
|
||||||
@ -4677,8 +4742,7 @@
|
|||||||
"node_modules/regenerator-runtime": {
|
"node_modules/regenerator-runtime": {
|
||||||
"version": "0.13.11",
|
"version": "0.13.11",
|
||||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"node_modules/regenerator-transform": {
|
"node_modules/regenerator-transform": {
|
||||||
"version": "0.15.1",
|
"version": "0.15.1",
|
||||||
@ -4783,6 +4847,11 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/restream": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/restream/-/restream-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-RpnOjVCRrc/jO6j1U+E0X9mPjMUUitjEms/IaR18wb8AdPHg46UBmB2aEA6JKgpGbhOcHsDLyurmeZhd4kQXgg=="
|
||||||
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
@ -5278,6 +5347,15 @@
|
|||||||
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/wrote": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/wrote/-/wrote-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-5vDwEuRou4yCOzR08bUdY+n/HuOA21L7A4tVsm/kEu2R2APN8tYWvxQbM1hFJk49lR7x47KZMtCu2k8S9WISUA==",
|
||||||
|
"dependencies": {
|
||||||
|
"catchment": "1.0.0",
|
||||||
|
"makepromise": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/y18n": {
|
"node_modules/y18n": {
|
||||||
"version": "5.0.8",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
|
@ -25,8 +25,10 @@
|
|||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"exifr": "^7.1.3",
|
"exifr": "^7.1.3",
|
||||||
|
"i18next": "^23.2.6",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
|
"node-exiftool": "^2.3.0",
|
||||||
"node-fs": "^0.1.7"
|
"node-fs": "^0.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -36,6 +38,7 @@
|
|||||||
"@jest/globals": "^29.5.0",
|
"@jest/globals": "^29.5.0",
|
||||||
"babel-jest": "^29.5.0",
|
"babel-jest": "^29.5.0",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
|
"loglevel": "^1.8.1",
|
||||||
"nodemon": "^2.0.22",
|
"nodemon": "^2.0.22",
|
||||||
"ts-node": "^10.9.1"
|
"ts-node": "^10.9.1"
|
||||||
}
|
}
|
||||||
|
37
setup.mjs
Normal file
37
setup.mjs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
création de la config
|
||||||
|
*/
|
||||||
|
// import i18next from 'i18next'
|
||||||
|
import config_rangement from "./configs";
|
||||||
|
|
||||||
|
const { stdin, stdout } = process;
|
||||||
|
|
||||||
|
function prompt(question) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
stdin.resume();
|
||||||
|
stdout.write(question);
|
||||||
|
|
||||||
|
stdin.on('data', data => resolve(data.toString().trim()));
|
||||||
|
stdin.on('error', err => reject(err));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
try {
|
||||||
|
// const name = await prompt(i18next.t("home.title"))
|
||||||
|
const name = await prompt(`squoi le dossier de base des archives? [${config_rangement.base_archive_folder}]`)
|
||||||
|
// const age = await prompt("What's your age? ");
|
||||||
|
// const email = await prompt("What's your email address? ");
|
||||||
|
// const user = { name, age, email };
|
||||||
|
console.log(name);
|
||||||
|
stdin.pause();
|
||||||
|
} catch(error) {
|
||||||
|
console.log("There's an error!");
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
BIN
testFiles/meme/2023-06-26T18.53.59 FzjSx2YWcAEqsde -- meme.jpg
Normal file
BIN
testFiles/meme/2023-06-26T18.53.59 FzjSx2YWcAEqsde -- meme.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
testFiles/meme/eueueu -- meme.jpg
Normal file
BIN
testFiles/meme/eueueu -- meme.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
Loading…
Reference in New Issue
Block a user