Update trierPhoto.php
This commit is contained in:
parent
1a678515a2
commit
227c151771
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/php
|
||||
<?PHP
|
||||
|
||||
if ($handle = opendir('.')) {
|
||||
|
@ -14,7 +15,7 @@ if ($handle = opendir('.')) {
|
|||
unset($dateTimeOriginal_explode);
|
||||
$traitement_ok = false;
|
||||
|
||||
$message='';
|
||||
$message='';
|
||||
$file_img_ok = false;
|
||||
$file_vid_ok = false;
|
||||
$file_exif_ok = false;
|
||||
|
@ -23,7 +24,7 @@ if ($handle = opendir('.')) {
|
|||
$file_date_ok = false;
|
||||
|
||||
if ($entry != "." && $entry != "..") {
|
||||
|
||||
|
||||
// Nom du fichier
|
||||
/**
|
||||
if (file_exists($entry)) {
|
||||
|
@ -64,8 +65,8 @@ if ($handle = opendir('.')) {
|
|||
$dateTimeOriginal['d'] = explode(" ", $dateTimeOriginal_explode[2])[0];
|
||||
}
|
||||
}
|
||||
$message .= " Traitement sur date EXIF";
|
||||
|
||||
$message .= " Traitement sur date EXIF\n";
|
||||
|
||||
}
|
||||
|
||||
// Lecture du nom du fichier
|
||||
|
@ -88,10 +89,10 @@ if ($handle = opendir('.')) {
|
|||
|
||||
}
|
||||
|
||||
$message .= "Traitement sur nom du fichier";
|
||||
$message .= "Traitement sur nom du fichier\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Vérification des dates récupérées
|
||||
if ($traitement_ok &&
|
||||
isset($dateTimeOriginal) && is_array($dateTimeOriginal)) {
|
||||
|
@ -116,7 +117,7 @@ if ($handle = opendir('.')) {
|
|||
$dateTimeOriginal['d'] = $dateTimeOriginal_explode[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Création des dossiers et déplacement du fichier
|
||||
if ($traitement_ok && isset($dateTimeOriginal) && is_array($dateTimeOriginal)) {
|
||||
$rep_dest = $dateTimeOriginal['y'] ."/". $dateTimeOriginal['m'] ."/". $dateTimeOriginal['d'];
|
||||
|
@ -126,23 +127,23 @@ if ($handle = opendir('.')) {
|
|||
}
|
||||
}
|
||||
|
||||
$file_dest = $rep_dest."/".$entry;
|
||||
if (!file_exists($file_dest)) {
|
||||
rename($entry, $file_dest);
|
||||
$message .= " => ".$file_dest."\n";
|
||||
} else {
|
||||
$md5_file_src = md5_file($entry);
|
||||
$md5_file_dst = md5_file($file_dest);
|
||||
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";
|
||||
unlink($entry);
|
||||
} else {
|
||||
$message .= " [ERREUR] ".$file_dest." existe déjà !\n";
|
||||
}
|
||||
|
||||
}
|
||||
fwrite($file_log_out, $message);
|
||||
echo $message;
|
||||
$file_dest = $rep_dest."/".$entry;
|
||||
if (!file_exists($file_dest)) {
|
||||
rename($entry, $file_dest);
|
||||
$message .= " => ".$file_dest."\n";
|
||||
} else {
|
||||
$md5_file_src = md5_file($entry);
|
||||
$md5_file_dst = md5_file($file_dest);
|
||||
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";
|
||||
unlink($entry);
|
||||
} else {
|
||||
$message .= " [ERREUR] ".$file_dest." existe déjà ! Mais pas avec la même empreinte.\n";
|
||||
}
|
||||
|
||||
}
|
||||
fwrite($file_log_out, $message);
|
||||
echo $message;
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,7 +151,7 @@ if ($handle = opendir('.')) {
|
|||
}
|
||||
|
||||
closedir($handle);
|
||||
|
||||
fclose($file_log_out);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue