add debug data
This commit is contained in:
parent
5ac004d194
commit
91a61d2c07
1
index.ts
1
index.ts
@ -25,6 +25,7 @@ log.info(' ')
|
||||
|
||||
|
||||
finder.parseArguments()
|
||||
finder.guessFileNameOnAllFilesFromArguments()
|
||||
|
||||
|
||||
console.log('hello ts', finder)
|
BIN
testFiles/misnamed_file/2000-01-01T01.01.01 sunglasses are 2005 in reality.jpg
Executable file
BIN
testFiles/misnamed_file/2000-01-01T01.01.01 sunglasses are 2005 in reality.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.0 MiB |
@ -76,6 +76,7 @@ export default class finder {
|
||||
static guessFileNameOnOnefile(fullPath: string): void {
|
||||
|
||||
log.info('go guess file name on file: ', fullPath)
|
||||
|
||||
fs.stat(fullPath, (err, stats) => {
|
||||
|
||||
if (err) {
|
||||
@ -84,31 +85,39 @@ export default class finder {
|
||||
return
|
||||
} else {
|
||||
|
||||
log.debug(' -------- le fichier existe bien, déstructuration')
|
||||
let structureForFile = this.destructurateFileName(fullPath)
|
||||
log.debug(' -------- ', fullPath)
|
||||
log.debug(' -------- ', structureForFile)
|
||||
|
||||
// examiner les infos exif de chaque fichier pour proposer un nouveau nom
|
||||
if (!structureForFile.dateStampInFileNameOriginal) {
|
||||
log.info(' le nom de fichier "' + structureForFile.freeText + '" ne contient pas de date formatée au début')
|
||||
|
||||
this.findExifCreationDate(structureForFile.fullPath)
|
||||
.then(data => {
|
||||
log.info(' ... chercher la date de création : "' + structureForFile.freeText + '"')
|
||||
let foundDate = this.findEarliestDateInExifData(data)
|
||||
|
||||
log.info(' =>>>>>>> foundDate : ', foundDate)
|
||||
if (foundDate) {
|
||||
structureForFile.dateStampExif = foundDate
|
||||
} else {
|
||||
log.info('pas de date trouvée dans le nom')
|
||||
}
|
||||
this.shouldWeChangeName(structureForFile)
|
||||
}
|
||||
,
|
||||
(error) => {
|
||||
log.warn('/////////// Error in reading exif of file: ' + error.message)
|
||||
return ''
|
||||
})
|
||||
} else {
|
||||
log.debug(' -------- dateStampInFileNameOriginal: ', structureForFile.dateStampInFileNameOriginal)
|
||||
}
|
||||
let fetchplace = cwd+'/'+structureForFile.fullPath
|
||||
log.debug(' -------- trouver les infos exif', fetchplace)
|
||||
this.findExifCreationDate(fetchplace)
|
||||
.then(data => {
|
||||
log.info(' ... chercher la date de création : "' + structureForFile.freeText + '"')
|
||||
log.debug('data', data)
|
||||
let foundDate = this.findEarliestDateInExifData(data)
|
||||
|
||||
log.info(' =>>>>>>> foundDate : ', foundDate)
|
||||
if (foundDate) {
|
||||
structureForFile.dateStampExif = foundDate
|
||||
} else {
|
||||
log.info('pas de date trouvée dans le nom')
|
||||
}
|
||||
this.shouldWeChangeName(structureForFile)
|
||||
}
|
||||
,
|
||||
(error) => {
|
||||
log.warn('/////////// Error in reading exif of file: ' + error.message)
|
||||
return ''
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
@ -156,7 +165,7 @@ export default class finder {
|
||||
static guessFileNameOnAllFilesFromArguments(): void {
|
||||
|
||||
// parcourir les fichiers
|
||||
log.debug('liste des fichiers', this.mini_arguments._)
|
||||
log.debug('_____________ liste des fichiers', this.mini_arguments._)
|
||||
let fileList = this.mini_arguments._
|
||||
|
||||
// test file exists
|
||||
@ -168,7 +177,9 @@ export default class finder {
|
||||
)
|
||||
|
||||
log.info('expanded file list :', this.expandedFileList)
|
||||
this.expandedFileList.forEach((filePath: string) => this.guessFileNameOnOnefile(filePath))
|
||||
this.expandedFileList.forEach((filePath: string) => {
|
||||
this.guessFileNameOnOnefile(filePath)
|
||||
})
|
||||
|
||||
if (rangement_instance.reportStatistics || this.mini_arguments.stats) {
|
||||
finder.reportStatistics()
|
||||
@ -475,7 +486,7 @@ export default class finder {
|
||||
|
||||
return minDate.format(rangement_instance.iso_date_format)
|
||||
} else {
|
||||
log.debug(' finder - /!\\ pas de exif data')
|
||||
log.debug(' finder - 😥 /!\\ pas de exif data')
|
||||
return ''
|
||||
}
|
||||
}
|
||||
@ -497,14 +508,18 @@ export default class finder {
|
||||
*/
|
||||
static async findExifCreationDate(filepath: string) {
|
||||
|
||||
log.debug(' finder - filepath', filepath)
|
||||
log.debug(' -------- findExifCreationDate')
|
||||
let dateAlreadyInFileName = finder.findFormattedDate(filepath)
|
||||
if (dateAlreadyInFileName) {
|
||||
|
||||
log.debug(' finder - ------ dateAlreadyInFileName', dateAlreadyInFileName)
|
||||
} else {
|
||||
log.debug(' -------- pas de date présente')
|
||||
}
|
||||
|
||||
return await exifr.parse(filepath)
|
||||
let exifPromise = await exifr.parse(filepath);
|
||||
log.debug(' -------- exifdata', exifPromise)
|
||||
|
||||
return exifPromise
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user