detect saut de séquence

This commit is contained in:
Tykayn 2023-12-21 16:09:19 +01:00 committed by tykayn
parent e0dcf24ab3
commit 0d7a847ecd
2 changed files with 43 additions and 17 deletions

View File

@ -3,9 +3,14 @@ import path from "path";
// @ts-ignore
import minimist from 'minimist';
import * as childProcess from 'child_process';
let mini_arguments: any = minimist(process.argv.slice(2))
let enable_batch_move_assembled_files = false;
let should_exec_geovisio_upload = false;
let folder = `/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_a_assembler/`
let subfolder = ``
@ -24,15 +29,21 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number }
let minNumber: number = 0;
let maxNumber: number = 0;
let previousFileName = 0
// Boucler sur chaque fichier JPG dans le dossier
fs.readdirSync(dirPath).forEach(file => {
let currentFileName = path.extname(file)
// Vérifier si le fichier est un fichier JPG
if (path.extname(file) === '.jpg' || path.extname(file) === '.JPG') {
if (currentFileName === '.jpg' || currentFileName === '.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]);
if (previousFileName + 1 !== number) {
console.log('saut de nombre / séquence à ', previousFileName, number)
}
// Sauver le nombre minimal et maximal trouvé jusqu'à présent
if (minNumber === 0 && number > 0) {
minNumber = number;
@ -40,6 +51,8 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number }
if (number > maxNumber) {
maxNumber = number;
}
previousFileName = number
}
}
});
@ -85,6 +98,7 @@ function renameFile(fileName: string): void {
function createDirectory(folderName: string): void {
console.log('createDirectory', folderName)
if (!fs.existsSync(folderName)) {
fs.mkdirSync(folderName);
}
@ -108,12 +122,13 @@ function getFileNames(): string[] {
*/
function batch_move_assembled_files(startNumber: number, endNumber: number) {
const fileNames = getFileNames();
console.log('fileNames', fileNames)
for (let i = startNumber; i <= endNumber; i++) {
const fileName = `assemblage_0${i}.jpg`;
console.log('fileName', fileName)
// renameFile(fileName);
renameFile(fileName);
}
}
@ -121,11 +136,13 @@ function batch_move_assembled_files(startNumber:number,endNumber:number){
console.log(' déplacer les assemblages dans ' + envois_todo_panoramax, startNumber, endNumber)
createDirectory(envois_todo_panoramax);
if (enable_batch_move_assembled_files) {
batch_move_assembled_files(startNumber, endNumber)
}
import * as childProcess from 'child_process';
function executeCommand(command: string, folderName: string): void {
const fullCommand = `${command} "${folderName}"`;
@ -147,6 +164,10 @@ function exec_geovisio(envois_todo_panoramax:string): void {
executeCommand(command, folderName);
}
if (should_exec_geovisio_upload) {
exec_geovisio(envois_todo_panoramax);
} else {
console.log(' l envoi vers geovisio automatique est désactivé ')
}
console.log("exécuter geovisio upload")

View File

@ -3,7 +3,8 @@
conversion de données exif
Utilisation:
ts-node main.ts --goproMin=80800 --goproMax=80801 --goproSubFolder="rouen_oct23"
ts-node main.ts --goproMin=54903 --goproMax=56267 --goproSubFolder="INBOX_a_assembler/camaret1"
**/
@ -46,8 +47,6 @@ if (mini_arguments['goproMax']) {
}
let hugin_batch_command = 'bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ' + goproMin + ' ' + goproMax
let extension_photo_source = 'jpg'
extension_photo_source = 'JPG'
@ -155,10 +154,16 @@ function makeBashScriptHugin(minmax: any) {
// console.log('ptoContent', ptoContent)
writeFile(ptoFileName, ptoContent)
}else{
console.log('l écriture de fichiers PTO a été désactivée')
}
}
let hugin_batch_command = 'bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-gopro-fusion/exif_batch.sh ' + goproMin + ' ' + goproMax
if (addExifToolInScript) {
scriptsContent += '\n # complétion des données gps depuis une des photos assemblées' +
'\n' + hugin_batch_command + '\n'