testing folder with pictures
This commit is contained in:
parent
d1645f6744
commit
5f987701c7
@ -2,5 +2,5 @@
|
||||
export const tagSeparator = ' '
|
||||
export const tagSectionSeparator = '--'
|
||||
export const enableTestsLocally = false
|
||||
export const reportStatistics = true
|
||||
export const reportStatistics = false
|
||||
export const version = '1.0.0'
|
@ -163,7 +163,10 @@ export default class finder {
|
||||
|
||||
console.log('filepath', filepath)
|
||||
let dateAlreadyInFileName = finder.findFormattedDate(filepath)
|
||||
if(dateAlreadyInFileName){
|
||||
|
||||
console.log('------ dateAlreadyInFileName', dateAlreadyInFileName)
|
||||
}
|
||||
|
||||
exifr.parse(filepath).then(exifData => {
|
||||
|
||||
@ -171,17 +174,25 @@ export default class finder {
|
||||
|
||||
let moments = []
|
||||
|
||||
// console.log('exif data : ', exifData) // Do something with your data!
|
||||
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)
|
||||
}
|
||||
if (exifData.ModificationDateTime) {
|
||||
// console.log('image créée le : ModificationDateTime : ', exifData.ModificationDateTime) // Do something with your data!
|
||||
moments.push(exifData.ModificationDateTime)
|
||||
}
|
||||
if (exifData.ModifyDate) {
|
||||
|
||||
// console.log('image modifiée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
||||
// console.log('image créée le : ModifyDate : ', exifData.ModifyDate) // Do something with your data!
|
||||
moments.push(exifData.ModifyDate)
|
||||
}
|
||||
if (exifData.FileAccessDateTime) {
|
||||
moments.push(exifData.FileAccessDateTime)
|
||||
}
|
||||
if (exifData.FileInodeChangeDateTime) {
|
||||
moments.push(exifData.FileInodeChangeDateTime)
|
||||
}
|
||||
if (exifData.FileModificationDateTime) {
|
||||
|
||||
// console.log('image créée le : FileModificationDateTime : ', exifData.FileModificationDateTime) // Do something with your data!
|
||||
@ -199,12 +210,15 @@ export default class finder {
|
||||
})
|
||||
let minDate = moment.min(moments)
|
||||
|
||||
return minDate
|
||||
return minDate.format('Y-M-DTH:i:s')
|
||||
} else {
|
||||
console.log('pas de exif data')
|
||||
return null
|
||||
return ''
|
||||
}
|
||||
}).catch(error => console.log('Error: ' + error.message))
|
||||
}).catch(error => {
|
||||
console.log('/////////// Error in reading exif of file: ' + error.message)
|
||||
return ''
|
||||
})
|
||||
}
|
||||
|
||||
}
|
@ -24,7 +24,7 @@ console.log(' ')
|
||||
|
||||
function parseArguments () {
|
||||
mini_arguments = minimist(process.argv.slice(2))
|
||||
// console.log('arguments', mini_arguments)
|
||||
console.log('arguments', mini_arguments)
|
||||
}
|
||||
|
||||
parseArguments()
|
||||
@ -38,7 +38,12 @@ function renameFile (originalFileName, fileMixedNewName) {
|
||||
|
||||
|
||||
function makeFileNameFromProperties (fileProperties) {
|
||||
return finder.cleanSpaces(fileProperties.dateStamp + ' ' + fileProperties.freeText + ' ' + tagSectionSeparator + ' ' + fileProperties.tags.join(tagSeparator) + fileProperties.extension)
|
||||
|
||||
let tagPlace = '';
|
||||
if(fileProperties.tags.length){
|
||||
tagPlace = ' ' + tagSectionSeparator + ' '
|
||||
}
|
||||
return finder.cleanSpaces( fileProperties.dateStamp + ' ' + fileProperties.freeText + tagPlace + fileProperties.tags.join(tagSeparator) + fileProperties.extension).replace(+ ' ' + tagSectionSeparator + ' '+'.' ,'.')
|
||||
}
|
||||
|
||||
function appendFileName (fileProperties, newText) {
|
||||
@ -51,6 +56,37 @@ function prependFileName (fileProperties, newText) {
|
||||
return fileProperties
|
||||
}
|
||||
|
||||
function guessFileNameOnAllFilesFromArguments(){
|
||||
|
||||
// parcourir les dossiers
|
||||
// parcourir les fichiers
|
||||
|
||||
console.log('liste des fichiers', mini_arguments._)
|
||||
let fileList = mini_arguments._;
|
||||
fileList.forEach(fileName => {
|
||||
|
||||
let structureForFile = finder.destructurateFileName(fileName)
|
||||
// examiner les infos exif de chaque fichier pour proposer un nouveau nom
|
||||
if(!structureForFile.dateStamp){
|
||||
let foundDate = finder.findExifCreationDate(fileName)
|
||||
if(foundDate){
|
||||
structureForFile.dateStamp = (finder.findExifCreationDate(fileName) + '')
|
||||
}
|
||||
}
|
||||
|
||||
let newname = makeFileNameFromProperties(structureForFile)
|
||||
if(fileName !== newname ){
|
||||
|
||||
console.log(' nouveau nom:',newname )
|
||||
}else{
|
||||
console.log(' rien à changer' )
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
guessFileNameOnAllFilesFromArguments()
|
||||
|
||||
// run tests
|
||||
if (enableTestsLocally) {
|
||||
|
||||
|
BIN
rangement/testFiles/received_582637990728055.webp
Normal file
BIN
rangement/testFiles/received_582637990728055.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
BIN
rangement/testFiles/tempFileForShare_20210910-004429.jpg
Executable file
BIN
rangement/testFiles/tempFileForShare_20210910-004429.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
0
rangement/testFiles/un_document.pdf
Normal file
0
rangement/testFiles/un_document.pdf
Normal file
0
rangement/testFiles/une_photo.jpg
Normal file
0
rangement/testFiles/une_photo.jpg
Normal file
0
rangement/testFiles/une_photo_pas_pareil.jpg
Normal file
0
rangement/testFiles/une_photo_pas_pareil.jpg
Normal file
0
rangement/testFiles/une_photo_pas_pareil.png
Normal file
0
rangement/testFiles/une_photo_pas_pareil.png
Normal file
Loading…
Reference in New Issue
Block a user