Update trierPhoto.php

This commit is contained in:
Cédric Abonnel 2022-03-06 06:39:43 +00:00
parent 1a678515a2
commit 227c151771
1 changed files with 26 additions and 25 deletions

View File

@ -1,3 +1,4 @@
#!/usr/bin/php
<?PHP <?PHP
if ($handle = opendir('.')) { if ($handle = opendir('.')) {
@ -14,7 +15,7 @@ if ($handle = opendir('.')) {
unset($dateTimeOriginal_explode); unset($dateTimeOriginal_explode);
$traitement_ok = false; $traitement_ok = false;
$message=''; $message='';
$file_img_ok = false; $file_img_ok = false;
$file_vid_ok = false; $file_vid_ok = false;
$file_exif_ok = false; $file_exif_ok = false;
@ -64,7 +65,7 @@ if ($handle = opendir('.')) {
$dateTimeOriginal['d'] = explode(" ", $dateTimeOriginal_explode[2])[0]; $dateTimeOriginal['d'] = explode(" ", $dateTimeOriginal_explode[2])[0];
} }
} }
$message .= " Traitement sur date EXIF"; $message .= " Traitement sur date EXIF\n";
} }
@ -88,7 +89,7 @@ if ($handle = opendir('.')) {
} }
$message .= "Traitement sur nom du fichier"; $message .= "Traitement sur nom du fichier\n";
} }
@ -126,23 +127,23 @@ if ($handle = opendir('.')) {
} }
} }
$file_dest = $rep_dest."/".$entry; $file_dest = $rep_dest."/".$entry;
if (!file_exists($file_dest)) { if (!file_exists($file_dest)) {
rename($entry, $file_dest); rename($entry, $file_dest);
$message .= " => ".$file_dest."\n"; $message .= " => ".$file_dest."\n";
} else { } else {
$md5_file_src = md5_file($entry); $md5_file_src = md5_file($entry);
$md5_file_dst = md5_file($file_dest); $md5_file_dst = md5_file($file_dest);
if ($md5_file_src == $md5_file_dst) { if ($md5_file_src == $md5_file_dst) {
$message .= " [ERREUR] ".$file_dest." existe déjà ! Destruction car même empreinte $md5_file_src / $md5_file_dst\n"; $message .= " [ERREUR] ".$file_dest." existe déjà ! Destruction car même empreinte $md5_file_src / $md5_file_dst\n";
unlink($entry); unlink($entry);
} else { } else {
$message .= " [ERREUR] ".$file_dest." existe déjà !\n"; $message .= " [ERREUR] ".$file_dest." existe déjà ! Mais pas avec la même empreinte.\n";
} }
} }
fwrite($file_log_out, $message); fwrite($file_log_out, $message);
echo $message; echo $message;
} }
@ -150,7 +151,7 @@ if ($handle = opendir('.')) {
} }
closedir($handle); closedir($handle);
fclose($file_log_out); fclose($file_log_out);
} }