Bonjour à vous,
J'ai un stock de fichiers qui ont les mauvaises extensions (ou pas du tout d'extension) que j'ai extrait de plusieurs apk (fichiers d'application android) et j'aimerai faire un programme qui renomme automatiquement leur extensions vers les bonnes
Pour l'instant j'en suis là :
python 3.8 me dit ça
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import os for element in os.listdir('C:/Users/yohan/Desktop/python'): file = open(f'C:/Users/yohan/Desktop/python/{element}') magic = file.read(4) file.close() b0 = ord(magic[0]) b1 = ord(magic[1]) b2 = ord(magic[2]) b3 = ord(magic[3]) if (b0==255 and b1==216 and b2==255): os.rename(element,__name__.jpeg) if (b0==79 and b1==103 and b2==103): os.rename(element,__name__.ogg) if (b0==71 and b1==73 and b2==70 & b3==56): os.rename(element,__name__.gif) if (b0==66 and b1==77): os.rename(element,__name__.bmp) if (b0==137 and b1==80 and b2==78 and b3==71): os.rename(element,__name__.png)
tandis que python 2.7 me dit qu'il y a une erreur de synthaxe sur l'apostrophe à la ligne 3 après {element}
Pouvez vous m'aider à le faire fonctionner svp ?
Partager