Код: Выделить всё
import os
import piexif
import datetime
dir_path = '/storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Images'
img_count = 1
for root, dirs, files in os.walk(dir_path):
for fname in files:
if fname.lower().endswith(('.jpg', '.jpeg', '.png', '.gif')):
img_path = os.path.join(root, fname)
exif_dict = piexif.load(img_path)
if not exif_dict['Exif'].get(piexif.ExifIFD.DateTimeOriginal, ""):
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(img_path)).strftime("%Y:%m:%d %H:%M:%S")
exif_dict['Exif'][piexif.ExifIFD.DateTimeOriginal] = mtime
exif_bytes = piexif.dump(exif_dict)
piexif.insert(exif_bytes, img_path)
print(f"[{img_count}] DateTimeOriginal of {img_path} updated successfully to {mtime}")
img_count += 1
Код: Выделить всё
from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, ...])
Код: Выделить всё
Error importing module "android": this module is a part of Kivy
You cannot use it from elsewhere and you barely need it at all
This is not a bug, please do not report it via email or Google Play reviews, thank you for your understanding
Я также знаком с Java, поэтому я мог бы попробовать это, если я Python, это невозможно.
Подробнее здесь: https://stackoverflow.com/questions/775 ... ion-denied
Мобильная версия