mirror of
				https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
				synced 2025-10-09 17:02:45 +02:00 
			
		
		
		
	
		
			
	
	
		
			35 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			35 lines
		
	
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
|   | import os | ||
|  | import shutil | ||
|  | # certains fichiers org contenant du html ne sont pas convertis avec pandoc | ||
|  | # on les cherche et on les met de côté | ||
|  | 
 | ||
|  | def chercher_fichiers_org(dossier_source, dossier_destination): | ||
|  |     # Vérifier si le dossier de destination existe, sinon le créer | ||
|  |     if not os.path.exists(dossier_destination): | ||
|  |         os.makedirs(dossier_destination) | ||
|  | 
 | ||
|  |     # Parcourir tous les fichiers dans le dossier source | ||
|  |     for racine, dossiers, fichiers in os.walk(dossier_source): | ||
|  |         for fichier in fichiers: | ||
|  |             if fichier.endswith(".org"): | ||
|  |                 # Ouvrir le fichier en mode lecture | ||
|  |                 with open(os.path.join(racine, fichier), "r") as f: | ||
|  |                     contenu = f.read() | ||
|  | 
 | ||
|  |                 # Vérifier si ":html:" est dans le contenu du fichier | ||
|  |                 if ":html:" in contenu: | ||
|  |                     # Déplacer le fichier dans le dossier de destination | ||
|  |                     shutil.move(os.path.join(racine, fichier), os.path.join(dossier_destination, fichier)) | ||
|  |                     print(f"Le fichier {fichier} a été déplacé avec succès.") | ||
|  |                 else: | ||
|  |                     print(f"Le fichier {fichier} ne contient pas ':html:', il n'a pas été déplacé.") | ||
|  | 
 | ||
|  | if __name__ == "__main__": | ||
|  |     if len(os.sys.argv) != 3: | ||
|  |         print("Usage: python script.py <dossier_source> <dossier_destination>") | ||
|  |         exit(1) | ||
|  | 
 | ||
|  |     dossier_source = os.sys.argv[1] | ||
|  |     dossier_destination = os.sys.argv[2] | ||
|  | 
 | ||
|  |     chercher_fichiers_org(dossier_source, dossier_destination) |