Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Calculate the Total Render Time of your completed After Effects renders. More Info:
#!/usr/bin/env python3
# Command Line Usage: python3 /path/to/AERenderLogsFolder/
# Title:
# Description: Calculate the Total Render Time of your completed After Effects renders.
# Author:
# More Info:
import os
import sys
import datetime
class Main:
def __init__(self):
# get folder path as passed to the command in Terminal = sys.argv[1]
# set initial total time
self.totalTime = 0;
# set count for read log files
self.logCount = 0;
# check if folder exists, then walk
if os.path.exists(
sys.exit('Error: {} does not exist.\nExiting...'.format(
def __walkDir__(self):
# walk the directory recursively
for root, subdirs, files in os.walk(
# filter for txt files only
files = list(filter(lambda file: file.endswith('.txt'), files))
# iterate through txt files
for filename in files:
self.filename = filename
self.file_path = os.path.join(root, filename)
# when loop ends, print total time
if self.totalTime > 0:
print("\n---\n\nTotal Render Time: {}\n\n---\n".format(str(datetime.timedelta(seconds=self.totalTime))))
print("No render times found here. Choose another location.\n\n---\n")
def __getElapsedTime__(self):
with open (self.file_path, 'rt') as myfile:
# iterate line by line: if elapsed time exists, extract it
for line in myfile:
if "Elapsed" in line:
elapsedTime = line[line.rfind(":")+1:].strip()
self.logCount += 1
print("{}. {} reported in log file: {}".format(self.logCount, elapsedTime, self.filename))
def __extractTime__(self, et):
# extract the elapsed time, split values by commas
if "," in et:
et = et.split(',')
for i in et:
def __formatTime__(self, t):
# get strings
s = [s for s in t.split() if not s.isdigit()][0]
# get digits
d = [int(s) for s in t.split() if s.isdigit()][0]
# return seconds
def sc():
return d
# convert minutes to seconds
def mn():
return d*60
# convert hours to seconds
def hr():
return d*3600
f = {
"Sec": sc,
"Seconds": sc,
"Second": sc,
"Min": mn,
"Minutes": mn,
"Minute": mn,
"Hr": hr,
"Hours": hr,
"Hour": hr
# find whether value is Hours, Minutes, or Seconds
# convert all to seconds, then accumulate
self.totalTime += f[s]()
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment