This commit is contained in:
SeungheeOh 2019-03-15 22:53:04 +09:00
parent 34ae0d90da
commit 33f43d2e3b

63
exif.py
View File

@ -124,48 +124,33 @@ def files(path):
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
yield file
folder = "./data/"
filenames = os.listdir(folder)
targetfolder = "./data/"
def photoupload(targetfolder):
filenames = os.listdir(targetfolder)
testfiles = [ x for x in filenames if os.path.isfile(os.path.join(targetfolder,x)) == True ]
testfiles = [ x for x in filenames if os.path.isfile(os.path.join(folder,x)) == True ]
testdirs = [ x for x in filenames if os.path.isdir(os.path.join(targetfolder,x)) == True ]
for testdir in testdirs:
photoupload(testdir)
testdirs = [ x for x in filenames if os.path.isfile(os.path.join(folder,x)) == True ]
for filename in testdirs:
print (filename)
#print (testfiles)
#exit()
#def print_all_metadata_atoms(file):
# atoms = file.findall('.//data')
# for atom in atoms:
# data = atom.get_attribute('data')
# print (atom.parent.name, data)
#for filename in filenames:
for filename in testfiles:
# newfilename = filename.encode('utf-8')
for filename in testfiles:
# newfilename = filename.encode('utf-8')
targetname,targetext = os.path.splitext(filename)
pathfile = folder+filename
f2 = "./done/"+filename
f = open(pathfile,'rb')
if targetext == ".mp4":
print (".mp4")
# print_all_metadata_atoms(Mp4File(pathfile))
# exit()
# print_all_metadata_atoms(Mp4File(pathfile))
# exit()
else:
tags = exifread.process_file(f, stop_tag=exif_choice)
# print (pathfile)
# print (pathfile)
for tag in tags.keys():
if tag in (exif_choice):
photodatetime=tags[tag]
@ -196,3 +181,25 @@ for filename in testfiles:
pass
#print (T)
#print ("Key: %s, value %s" % (tag, tags[tag]))
photoupload(targetfolder)
#print (testfiles)
#exit()
#def print_all_metadata_atoms(file):
# atoms = file.findall('.//data')
# for atom in atoms:
# data = atom.get_attribute('data')
# print (atom.parent.name, data)
#for filename in filenames: