find tags and extension of file
This commit is contained in:
parent
2a2ece88a7
commit
dabebeb6fa
|
@ -24,68 +24,88 @@ function convertDateToTimeInFileName (inputDate) {
|
|||
return inputDate.replace(' ', 'T')
|
||||
}
|
||||
|
||||
function findFormattedDate(inputString){
|
||||
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}$/)
|
||||
}
|
||||
|
||||
function getExifCreationDate (filepath) {
|
||||
|
||||
console.log('filepath', filepath)
|
||||
|
||||
exifr.parse(filepath).then(exifData => {
|
||||
|
||||
exifr.parse(filepath).then(exifData => {
|
||||
|
||||
if (exifData) {
|
||||
|
||||
let moments = []
|
||||
let moments = []
|
||||
|
||||
// console.log('exif data : ', exifData) // Do something with your data!
|
||||
if (exifData.DateTimeOriginal) {
|
||||
// console.log('exif data : ', exifData) // Do something with your data!
|
||||
if (exifData.DateTimeOriginal) {
|
||||
|
||||
// console.log('image créée le : DateTimeOriginal : ', exifData.DateTimeOriginal) // Do something with your data!
|
||||
moments.push(exifData.DateTimeOriginal)
|
||||
}
|
||||
// console.log('image créée le : DateTimeOriginal : ', exifData.DateTimeOriginal) // Do something with your data!
|
||||
moments.push(exifData.DateTimeOriginal)
|
||||
}
|
||||
if (exifData.ModifyDate) {
|
||||
|
||||
// console.log('image modifiée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
||||
moments.push(exifData.ModifyDate)
|
||||
}
|
||||
if (exifData.FileModificationDateTime) {
|
||||
|
||||
// console.log('image créée le : FileModificationDateTime : ', exifData.FileModificationDateTime) // Do something with your data!
|
||||
moments.push(exifData.FileModificationDateTime)
|
||||
}
|
||||
if (exifData.CreateDate) {
|
||||
|
||||
// console.log('image créée le : CreateDate : ', exifData.CreateDate) // Do something with your data!
|
||||
moments.push(exifData.CreateDate)
|
||||
}
|
||||
|
||||
moments = moments.map(d => {
|
||||
let newdate = moment(d)
|
||||
return newdate
|
||||
})
|
||||
let minDate = moment.min(moments)
|
||||
|
||||
return minDate
|
||||
} else {
|
||||
console.log('pas de exif data')
|
||||
return null
|
||||
// console.log('image modifiée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
||||
moments.push(exifData.ModifyDate)
|
||||
}
|
||||
}).catch(error => console.log('Error: ' + error.message))
|
||||
if (exifData.FileModificationDateTime) {
|
||||
|
||||
// console.log('image créée le : FileModificationDateTime : ', exifData.FileModificationDateTime) // Do something with your data!
|
||||
moments.push(exifData.FileModificationDateTime)
|
||||
}
|
||||
if (exifData.CreateDate) {
|
||||
|
||||
// console.log('image créée le : CreateDate : ', exifData.CreateDate) // Do something with your data!
|
||||
moments.push(exifData.CreateDate)
|
||||
}
|
||||
|
||||
moments = moments.map(d => {
|
||||
let newdate = moment(d)
|
||||
return newdate
|
||||
})
|
||||
let minDate = moment.min(moments)
|
||||
|
||||
return minDate
|
||||
} else {
|
||||
console.log('pas de exif data')
|
||||
return null
|
||||
}
|
||||
}).catch(error => console.log('Error: ' + error.message))
|
||||
|
||||
}
|
||||
|
||||
const tagSeparator = ' '
|
||||
const tagSectionSeparator = '--'
|
||||
function findTagSectionInString(inputString){
|
||||
let fileSectionsName;
|
||||
|
||||
function findTagSectionInString (inputString) {
|
||||
let listOfTags = []
|
||||
if(inputString.includes(tagSectionSeparator)){
|
||||
let boom = inputString.splice(tagSectionSeparator)
|
||||
if(boom.length){
|
||||
listOfTags = [...boom.splice(tagSeparator)]
|
||||
// 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)) {
|
||||
console.log('inputString', inputString)
|
||||
if (inputString.length) {
|
||||
|
||||
let boom = inputString.split(tagSectionSeparator)
|
||||
console.log('boom', boom)
|
||||
if (boom.length) {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
// 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')
|
Loading…
Reference in New Issue