2023-12-09 12:02:54 +01:00
|
|
|
import fs from "node:fs";
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
import minimist from 'minimist';
|
|
|
|
|
|
|
|
let mini_arguments: any = minimist(process.argv.slice(2))
|
|
|
|
|
|
|
|
let folder = `/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_a_assembler/`
|
|
|
|
let subfolder = ``
|
|
|
|
|
|
|
|
if (mini_arguments['folder']) {
|
|
|
|
subfolder = mini_arguments['folder']
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* trouver les valeux min et max de numéros de séquence gopro dans un dossier contenant des photos jpg
|
|
|
|
* @param dirPath
|
|
|
|
*/
|
|
|
|
function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number } {
|
|
|
|
|
|
|
|
console.log('dirPath', dirPath)
|
|
|
|
|
|
|
|
let minNumber: number = 0;
|
|
|
|
let maxNumber: number = 0;
|
|
|
|
|
|
|
|
// Boucler sur chaque fichier JPG dans le dossier
|
|
|
|
fs.readdirSync(dirPath).forEach(file => {
|
|
|
|
// Vérifier si le fichier est un fichier JPG
|
|
|
|
if (path.extname(file) === '.jpg' || path.extname(file) === '.JPG') {
|
|
|
|
// Éxtraire le nombre du nom de fichier
|
|
|
|
let matches: any = file.match(/(\d+)/);
|
|
|
|
if (matches && matches.length && matches[0]) {
|
|
|
|
let number = parseInt(matches[0]);
|
|
|
|
|
|
|
|
// Sauver le nombre minimal et maximal trouvé jusqu'à présent
|
|
|
|
if (minNumber === 0 && number > 0) {
|
|
|
|
minNumber = number;
|
|
|
|
}
|
|
|
|
if (number > maxNumber) {
|
|
|
|
maxNumber = number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
min: minNumber,
|
|
|
|
max: maxNumber,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let result = findMinMaxNumberOfPhotos(folder + subfolder)
|
2023-12-10 17:58:57 +01:00
|
|
|
console.log('result', result)
|
|
|
|
console.log("script :\n", `
|
|
|
|
ts-node /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/main.ts --goproSubFolder=INBOX_a_assembler/${subfolder}
|
|
|
|
bash /home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_PTO_hugin/hugin_executor_from_${result.min}_to_${result.max}.sh
|
|
|
|
bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ${result.min} ${result.max} INBOX_a_assembler/${subfolder}
|
|
|
|
|
|
|
|
`)
|