-2

How to get and change file name to time timestamps from image(png or jpg) in same directory with python?

And I want to make a list of that files without file extension in text file.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • 1
    Does this answer your question? [Implement touch using Python?](https://stackoverflow.com/questions/1158076/implement-touch-using-python) – Robert Harvey Apr 28 '21 at 12:47

1 Answers1

0

This will give you the timestamp of image

from PIL import Image
def get_date_taken(path):
    return Image.open(path).getexif()[36867]

This will change the filename

import os
os.rename(r'file path\OLD file name.file type',r'file path\NEW file name.file type')

And finally you can find all images with this code

from os import walk

f = []
for (dirpath, dirnames, filenames) in walk(mypath):
    f.extend(filenames)
    break

Try to combine all of these codes.