detect saut de séquence
This commit is contained in:
parent
e0dcf24ab3
commit
0d7a847ecd
|
@ -3,9 +3,14 @@ import path from "path";
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import minimist from 'minimist';
|
import minimist from 'minimist';
|
||||||
|
import * as childProcess from 'child_process';
|
||||||
|
|
||||||
let mini_arguments: any = minimist(process.argv.slice(2))
|
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 folder = `/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/INBOX_a_assembler/`
|
||||||
let subfolder = ``
|
let subfolder = ``
|
||||||
|
|
||||||
|
@ -24,15 +29,21 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number }
|
||||||
let minNumber: number = 0;
|
let minNumber: number = 0;
|
||||||
let maxNumber: number = 0;
|
let maxNumber: number = 0;
|
||||||
|
|
||||||
|
let previousFileName = 0
|
||||||
// Boucler sur chaque fichier JPG dans le dossier
|
// Boucler sur chaque fichier JPG dans le dossier
|
||||||
fs.readdirSync(dirPath).forEach(file => {
|
fs.readdirSync(dirPath).forEach(file => {
|
||||||
|
|
||||||
|
let currentFileName = path.extname(file)
|
||||||
// Vérifier si le fichier est un fichier JPG
|
// 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
|
// Éxtraire le nombre du nom de fichier
|
||||||
let matches: any = file.match(/(\d+)/);
|
let matches: any = file.match(/(\d+)/);
|
||||||
if (matches && matches.length && matches[0]) {
|
if (matches && matches.length && matches[0]) {
|
||||||
let number = parseInt(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
|
// Sauver le nombre minimal et maximal trouvé jusqu'à présent
|
||||||
if (minNumber === 0 && number > 0) {
|
if (minNumber === 0 && number > 0) {
|
||||||
minNumber = number;
|
minNumber = number;
|
||||||
|
@ -40,6 +51,8 @@ function findMinMaxNumberOfPhotos(dirPath: string): { min: number, max: number }
|
||||||
if (number > maxNumber) {
|
if (number > maxNumber) {
|
||||||
maxNumber = number;
|
maxNumber = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previousFileName = number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,7 +73,7 @@ bash /home/poule/encrypted/stockage-syncable/www/development/html/scripts/hugin-
|
||||||
`)
|
`)
|
||||||
|
|
||||||
const hugin_assemblages_script_output_path = '/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/hugin_assemblages_script_output';
|
const hugin_assemblages_script_output_path = '/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/hugin_assemblages_script_output';
|
||||||
const envois_todo_panoramax = '/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/PANORAMAX_envois_todo/'+subfolder;
|
const envois_todo_panoramax = '/home/poule/encrypted/stockage-syncable/photos/imageries/gopro/PANORAMAX_envois_todo/' + subfolder;
|
||||||
const startNumber = result.min;
|
const startNumber = result.min;
|
||||||
const endNumber = result.max;
|
const endNumber = result.max;
|
||||||
|
|
||||||
|
@ -72,19 +85,20 @@ function renameFile(fileName: string): void {
|
||||||
|
|
||||||
if (fs.existsSync(filePath)) {
|
if (fs.existsSync(filePath)) {
|
||||||
const newFileName = `assemblage_0${startNumber}.jpg`;
|
const newFileName = `assemblage_0${startNumber}.jpg`;
|
||||||
const newFilePath = path.join(envois_todo_panoramax , newFileName);
|
const newFilePath = path.join(envois_todo_panoramax, newFileName);
|
||||||
|
|
||||||
|
console.log('rename: ', filePath, newFilePath)
|
||||||
|
|
||||||
console.log('rename: ', filePath , newFilePath)
|
|
||||||
|
|
||||||
|
|
||||||
fs.renameSync(filePath, newFilePath);
|
fs.renameSync(filePath, newFilePath);
|
||||||
}else{
|
} else {
|
||||||
console.log('ce fichier est inexistant', filePath)
|
console.log('ce fichier est inexistant', filePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createDirectory(folderName: string): void {
|
function createDirectory(folderName: string): void {
|
||||||
|
console.log('createDirectory', folderName)
|
||||||
if (!fs.existsSync(folderName)) {
|
if (!fs.existsSync(folderName)) {
|
||||||
fs.mkdirSync(folderName);
|
fs.mkdirSync(folderName);
|
||||||
}
|
}
|
||||||
|
@ -106,25 +120,28 @@ function getFileNames(): string[] {
|
||||||
* @param startNumber
|
* @param startNumber
|
||||||
* @param endNumber
|
* @param endNumber
|
||||||
*/
|
*/
|
||||||
function batch_move_assembled_files(startNumber:number,endNumber:number){
|
function batch_move_assembled_files(startNumber: number, endNumber: number) {
|
||||||
const fileNames = getFileNames();
|
const fileNames = getFileNames();
|
||||||
|
console.log('fileNames', fileNames)
|
||||||
|
|
||||||
for (let i = startNumber; i <= endNumber; i++) {
|
for (let i = startNumber; i <= endNumber; i++) {
|
||||||
const fileName = `assemblage_0${i}.jpg`;
|
const fileName = `assemblage_0${i}.jpg`;
|
||||||
|
|
||||||
console.log('fileName', fileName)
|
console.log('fileName', fileName)
|
||||||
// renameFile(fileName);
|
renameFile(fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(' déplacer les assemblages dans '+envois_todo_panoramax, startNumber, endNumber)
|
console.log(' déplacer les assemblages dans ' + envois_todo_panoramax, startNumber, endNumber)
|
||||||
|
|
||||||
createDirectory(envois_todo_panoramax);
|
createDirectory(envois_todo_panoramax);
|
||||||
batch_move_assembled_files(startNumber,endNumber)
|
|
||||||
|
|
||||||
|
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 {
|
function executeCommand(command: string, folderName: string): void {
|
||||||
const fullCommand = `${command} "${folderName}"`;
|
const fullCommand = `${command} "${folderName}"`;
|
||||||
|
@ -140,13 +157,17 @@ function executeCommand(command: string, folderName: string): void {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exec_geovisio(envois_todo_panoramax:string): void {
|
function exec_geovisio(envois_todo_panoramax: string): void {
|
||||||
const folderName = envois_todo_panoramax;
|
const folderName = envois_todo_panoramax;
|
||||||
const command = 'geovisio upload --api-url https://panoramax.openstreetmap.fr';
|
const command = 'geovisio upload --api-url https://panoramax.openstreetmap.fr';
|
||||||
|
|
||||||
executeCommand(command, folderName);
|
executeCommand(command, folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_geovisio(envois_todo_panoramax);
|
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")
|
console.log("exécuter geovisio upload")
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
conversion de données exif
|
conversion de données exif
|
||||||
|
|
||||||
Utilisation:
|
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'
|
let extension_photo_source = 'jpg'
|
||||||
extension_photo_source = 'JPG'
|
extension_photo_source = 'JPG'
|
||||||
|
@ -155,10 +154,16 @@ function makeBashScriptHugin(minmax: any) {
|
||||||
|
|
||||||
// console.log('ptoContent', ptoContent)
|
// console.log('ptoContent', ptoContent)
|
||||||
writeFile(ptoFileName, 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) {
|
if (addExifToolInScript) {
|
||||||
scriptsContent += '\n # complétion des données gps depuis une des photos assemblées' +
|
scriptsContent += '\n # complétion des données gps depuis une des photos assemblées' +
|
||||||
'\n' + hugin_batch_command + '\n'
|
'\n' + hugin_batch_command + '\n'
|
||||||
|
|
Loading…
Reference in New Issue