zip zip zip
This commit is contained in:
parent
a6755863dd
commit
c8aaa78f59
5 changed files with 175 additions and 33 deletions
|
@ -3,16 +3,18 @@
|
|||
import os
|
||||
import re
|
||||
import typing
|
||||
import datetime
|
||||
|
||||
import PIL.ExifTags
|
||||
import PIL.Image
|
||||
import progressbar
|
||||
|
||||
EXTENSION_PATTERN = re.compile(r'\.JPE?G', re.I)
|
||||
COMMON_PATTERN = re.compile(r'(IMG|DSC[NF]?|100|P10)_?\d+', re.I)
|
||||
COMMON_PATTERN = re.compile(r'(IMG|DSC[NF]?|100|P10|f|t)_?\d+', re.I)
|
||||
EXIF_TAG_NAME = 'DateTimeOriginal'
|
||||
EXIF_TAG_ID = list(PIL.ExifTags.TAGS.keys())[list(
|
||||
PIL.ExifTags.TAGS.values()).index(EXIF_TAG_NAME)]
|
||||
EXIF_DATE_FORMAT = '%Y:%m:%d %H:%M:%S'
|
||||
|
||||
|
||||
def get_pictures(directory: str = ".", skip_renamed: bool = True) \
|
||||
|
@ -41,7 +43,10 @@ def main() -> None:
|
|||
exif_data = img._getexif()
|
||||
if exif_data and EXIF_TAG_ID in exif_data:
|
||||
date_raw = exif_data[EXIF_TAG_ID]
|
||||
# print(date_raw, full_path)
|
||||
date = datetime.datetime.strptime(date_raw, EXIF_DATE_FORMAT)
|
||||
new_name = date.isoformat().replace(':', '-') + '.jpg' # For NTFS
|
||||
print(full_path, new_name)
|
||||
os.rename(full_path, new_name) # TODO FOLDER
|
||||
img.close()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue