find tags and extension of file

This commit is contained in:
Tykayn 2023-06-27 18:12:43 +02:00 committed by tykayn
parent 2a2ece88a7
commit dabebeb6fa
1 changed files with 60 additions and 41 deletions

View File

@ -28,6 +28,7 @@ function findFormattedDate(inputString){
return inputString.match(/^[0-9]{4}-?[0-9]{2}-?[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/) return inputString.match(/^[0-9]{4}-?[0-9]{2}-?[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/)
} }
function getExifCreationDate (filepath) { function getExifCreationDate (filepath) {
console.log('filepath', filepath) console.log('filepath', filepath)
@ -77,15 +78,34 @@ function getExifCreationDate (filepath) {
const tagSeparator = ' ' const tagSeparator = ' '
const tagSectionSeparator = '--' const tagSectionSeparator = '--'
let fileSectionsName;
function findTagSectionInString (inputString) { function findTagSectionInString (inputString) {
let listOfTags = [] let listOfTags = []
// remove extension
let extensionFile = inputString.match(/\.\w{3,4}$/i)
extensionFile = extensionFile[0]
inputString = inputString.replace(extensionFile, '')
console.log('extensionFile', extensionFile)
if (inputString.includes(tagSectionSeparator)) { if (inputString.includes(tagSectionSeparator)) {
let boom = inputString.splice(tagSectionSeparator) console.log('inputString', inputString)
if (inputString.length) {
let boom = inputString.split(tagSectionSeparator)
console.log('boom', boom)
if (boom.length) { if (boom.length) {
listOfTags = [...boom.splice(tagSeparator)] fileSectionsName = boom.splice(tagSeparator);
listOfTags = [... fileSectionsName[1].trim().split(tagSeparator)]
console.log('listOfTags', listOfTags)
}else{
console.log('no boom', boom)
} }
} }
return listOfTags; }
return listOfTags
} }
/** /**
@ -135,6 +155,5 @@ const patternsFiles = {
'screenshot': '^Screenshot', // Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png 'screenshot': '^Screenshot', // Screenshot 2023-06-15 at 15-26-04 Instance Panoramax OSM-FR.png
} }
// getExifCreationDate('/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/2023-06-23T18.36.47 -- machin bidule.jpg') // getExifCreationDate('/home/poule/encrypted/stockage-syncable/photos/a_dispatcher/2023-06-23T18.36.47 -- machin bidule.jpg')
findTagSectionInString('2023-06-23T18.36.47 -- machin bidule.jpg') findTagSectionInString('2023-06-23T18.36.47 -- machin bidule.jpg')