Skip to content

Instantly share code, notes, and snippets.

@yamadaaaaaaa
Last active January 19, 2022 06:38
Show Gist options
  • Select an option

  • Save yamadaaaaaaa/ece5189a18e20c3c5f11cb712bb79eed to your computer and use it in GitHub Desktop.

Select an option

Save yamadaaaaaaa/ece5189a18e20c3c5f11cb712bb79eed to your computer and use it in GitHub Desktop.
check_exr.py
import os
import sys
import OpenEXR
# change path ###############
TARGET_PATH = 'D:/test'
#############################
def main():
list_exr = list()
list_size = list()
list_seq = list()
if not os.path.exists(TARGET_PATH):
return
print('----- check start -----')
print('<'+TARGET_PATH+'>')
for curDir, dirs, files in os.walk(TARGET_PATH):
if not files:continue
print(curDir)
if files[0].count(".exr") != 0 or files[0].count(".tga") != 0 or files[0].count(".jpg") != 0 or files[0].count(".tiff") != 0 or files[0].count(".png") != 0:
_start = None
for _file in files:
_path = os.path.join(curDir,_file)
# exr
try:
img_exr = OpenEXR.InputFile(_path)
except Exception as e:
list_exr.append(_path)
# size
if os.path.getsize(_path) <= 100:
list_size.append(_path)
# sequence
_name, _exr = os.path.splitext( os.path.basename( _path ))
_name = _name.split('.').pop()
if _start == None:
_start = int(_name)
else:
if (_start + 1) != int(_name):
list_seq.append(_path.replace('.'+_name+'.','.'+str(int(_name)-1)+'.'))
_start = int(_name)
_result = os.path.join(r"C:\Users",os.environ["USERNAME"],"Desktop","check_exr.txt")
if not list_exr and not list_size and not list_seq:return
with open(_result,"w", newline='') as f:
if list_exr:
f.write("EXR ERROR*************"+ os.linesep)
for _file in list_exr:
f.write(_file + os.linesep)
f.write(os.linesep)
if list_size:
f.write("SIZE ERROR*************"+ os.linesep)
for _file in list_size:
f.write(_file + os.linesep)
f.write(os.linesep)
if list_seq:
f.write("SEQUENCE ERROR*************"+ os.linesep)
for _file in list_seq:
f.write(_file + os.linesep)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment