mercredi 18 septembre 2019

How to fix my Inconsistent if statement in Python

I have written a python script that renames my Photos. Basically it iterates through all image files, reads out the datetime in the EXIF Data and renames a file according to AAAA-MM-DD-hh-mm-ss. Finally it puts them into folders /Pictures/AAAA/AAAA-MM/

Some pictures have empty EXIF Data and some other have the entry DATE: 0000-00-00, Time: 00h00 I want the code to not touch these files and have written an if statement. But somehow python does not understand it and still renames the pictures with 0000 entries.

img = Image.open(filename)
        exif_data = img._getexif()
        if exif_data !=None: 
            DateTime=exif_data.get(36867)
            if DateTime != None and DateTime[0:4] !=0000:

Aucun commentaire:

Enregistrer un commentaire