I need to add a .jpg extension to around 300K pictures. They are all in 12 sub-directories and four more subdirectories in each of those 12.
I tried following this post but didn't do a walk down to all subdirectories: Adding extension to multiple files (Python3.5)
I also tried the following:
import os
path = 'C:\\Photos'
genmod = os.walk(path)
for path, pathnames, files in gen_obj:
for file in files:
head, tail = os.splitext(file)
if not tail:
src = os.path.join(path, pathnames, file)
dst = os.path.join(path, pathnames, file + '.jpg')
if not os.path.exists(dst): # check if the file doesn't exist
os.rename(src, dst)
The above runs but nothing happens.