Advertisement
Guest User

Video_ts2iso

a guest
Mar 9th, 2010
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. ## {{{ A simple recrusive directory walker that search for VIDEO_TS folders
  2. import sys
  3. import os
  4. from subprocess import call
  5.  
  6.  
  7. def setNumFile(path, fileName):
  8.     num = 0
  9.     while True:
  10.         num = num + 1
  11.         if not os.path.exists(path + "/" + fileName + '_[' + str(num) + ']' + ".iso"):
  12.             break
  13.            
  14.     return fileName + '_[' + str(num) + ']'
  15.  
  16. def callImgburn(path, name):
  17.     isoFolder = "D:\\burnISO"
  18.     if os.path.isfile(isoFolder + "/" + name + ".iso"):
  19.         name = setNumFile(isoFolder, name)
  20.     call(['C:\Program Files (x86)\ImgBurn\ImgBurn.exe', '/MODE', 'BUILD',
  21.     '/BUILDMODE', 'IMAGEFILE', '/NOIMAGEDETAILS', '/VOLUMELABEL', name,
  22.     '/SRC', path, '/DEST', isoFolder+'\\'+name+'.iso', '/START', '/CLOSE'])
  23.  
  24.  
  25. def checkDVDFolder(startDir, movieName):
  26.     imgBurnCalls = 0
  27.     directories = [startDir]
  28.     while len(directories)>0:
  29.         directory = directories.pop()
  30.         for name in os.listdir(directory):
  31.             fullpath = os.path.join(directory, name)
  32.             if os.path.isdir(fullpath):
  33.                 if os.path.basename(fullpath) == "VIDEO_TS":
  34.                     callImgburn(fullpath, movieName)
  35.                     imgBurnCalls = imgBurnCalls + 1
  36.                 directories.append(fullpath)  # It's a directory, store it.
  37.  
  38.     return imgBurnCalls
  39.  
  40. numCalls = checkDVDFolder(sys.argv[1], sys.argv[3])
  41. if numCalls <= 0:
  42.     print "Video2iso.py says: I cant find anny VIDEO_TS folders"
  43. else:
  44.     print "Video2iso.py says: I manufactured "+str(numCalls)+" iso files"
  45. ## End of the program }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement