Advertisement
iklio

Untitled

Jul 2nd, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import os
  3. import argparse
  4.  
  5.  
  6. if __name__ == "__main__":
  7.     parser = argparse.ArgumentParser(description='Check if subdirectories of the specified directory contain an nfo and one or more sfvs')
  8.     parser.add_argument("directory",
  9.                     help="The directory containing the scene releases")
  10.     args = parser.parse_args()
  11.  
  12.     dirList = os.listdir(args.directory) # current directory
  13.     for dir in dirList:
  14.         if os.path.isdir(dir) == True:
  15.             foundNfo = 0
  16.             foundSfv = 0
  17.             releasedir = os.path.abspath(os.path.join(args.directory, dir))
  18.             releasefiles = os.listdir(releasedir)
  19.             for f in releasefiles:
  20.                 if f.endswith(".nfo"):
  21.                     foundNfo = 1
  22.                 if f.endswith(".sfv"):
  23.                     foundSfv = 1
  24.             if foundNfo and foundSfv:
  25.                 pass #print dir + " ok"
  26.             else:
  27.                 # check subdirectories
  28.                 for root, subdir, files in os.walk(releasedir):
  29.                     for f in files:
  30.                         if f.endswith('.nfo'):
  31.                             if foundNfo == 0:
  32.                                 foundNfo = 2
  33.                         if f.endswith('.sfv'):
  34.                             foundSfv = 1
  35.                 if foundNfo == 1:
  36.                     if foundSfv == 1:
  37.                         pass #print dir + " ok"
  38.                     else:
  39.                         print dir + " is missing an sfv"
  40.                 elif foundNfo == 2:
  41.                     if foundSfv == 1:
  42.                         print dir + " has an nfo in a subdirectory"
  43.                     else:
  44.                         print dir + " is missing sfv and has an nfo in a subdirectory"
  45.                 else:
  46.                     if foundSfv == 1:
  47.                         print dir + " is missing an nfo"
  48.                     else:
  49.                         print dir + " is missing both nfo and sfv"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement