mapillary_download/move_already_sent.py
2025-07-28 12:15:43 +02:00

35 lines
1.2 KiB
Python

import os
import shutil
# Définition des chemins
found_in_france_path = 'found_in_france'
already_sent_path = 'already_sent'
# Vérification de l'existence des dossiers
if not os.path.exists(found_in_france_path):
print(f"Le dossier {found_in_france_path} n'existe pas.")
exit(1)
if not os.path.exists(already_sent_path):
os.makedirs(already_sent_path)
# Parcours des sous-dossiers
for dir_name in os.listdir(found_in_france_path):
dir_path = os.path.join(found_in_france_path, dir_name)
# Vérifier si c'est un dossier
if os.path.isdir(dir_path):
# Rechercher le fichier panoramax.txt dans le dossier
file_path = os.path.join(dir_path, '_panoramax.txt')
if os.path.exists(file_path):
# Déplacer le dossier vers already_sent
new_dir_path = os.path.join(already_sent_path, dir_name)
try:
shutil.move(dir_path, new_dir_path)
print(f"Dossier {dir_name} déplacé vers {already_sent_path}")
except Exception as e:
print(f"Erreur lors du déplacement de {dir_name} : {e}")
else:
print(f"Aucun fichier panoramax.txt trouvé dans {dir_name}")
else:
print(f"{dir_name} n'est pas un dossier.")