Skip to content

Instantly share code, notes, and snippets.

@sanfx
Last active December 16, 2015 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanfx/5374502 to your computer and use it in GitHub Desktop.
Save sanfx/5374502 to your computer and use it in GitHub Desktop.
Checks if sequence exist on disk. seqPath = image sequence path example: J:/Footages/33x01_02a/33x01_02a.%04d.sgi where %04d can be any sequence like 0001-0265, 231-689 but not KFd001- KFd567 string change buildPath at line 21 to customize for compatibility frstFrame = First frame as string lastFrame = Last frame as string
import os
def sequenceExists(seqPath, firstFrame, lastFrame, sep=None):
""" Checks if sequence exist on disk.
seqPath (string): image sequence path
example: J:/Footages/33x01_02a/33x01_02a.%04d.sgi
where %04d can be any sequence like 0001-0265, 231-689 but not KFd001- KFd567 string
change buildPath at line 21 to customize for compatibility
frstFrame (string): First frame as string
lastFrame (string): Last frame as string
"""
builPath = ""
fnSep = sep or "."
seqPathLst = seqPath.split(fnSep)
frmNumLen = len(firstFrame)
for each in range(int(firstFrame),int(lastFrame)+1):
newLen = frmNumLen - len(str(each))
numFmt = newLen* "0" + str(each)
buildPath = seqPathLst[0] + fnSep + numFmt + fnSep + seqPathLst[-1]
if not os.path.exists(buildPath):
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment