Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import argparse
- if __name__ == "__main__":
- parser = argparse.ArgumentParser(description='Check if subdirectories of the specified directory contain an nfo and one or more sfvs')
- parser.add_argument("directory",
- help="The directory containing the scene releases")
- args = parser.parse_args()
- dirList = os.listdir(args.directory) # current directory
- for dir in dirList:
- if os.path.isdir(dir) == True:
- foundNfo = 0
- foundSfv = 0
- releasedir = os.path.abspath(os.path.join(args.directory, dir))
- releasefiles = os.listdir(releasedir)
- for f in releasefiles:
- if f.endswith(".nfo"):
- foundNfo = 1
- if f.endswith(".sfv"):
- foundSfv = 1
- if foundNfo and foundSfv:
- print dir + " ok"
- else:
- # check subdirectories
- for root, subdir, files in os.walk(releasedir):
- for f in files:
- if f.endswith('.nfo'):
- if foundNfo == 0:
- foundNfo = 2
- if f.endswith('.sfv'):
- foundSfv = 1
- if foundNfo == 1:
- if foundSfv == 1:
- print dir + " ok"
- else:
- print dir + " is missing an sfv"
- elif foundNfo == 2:
- if foundSfv == 1:
- print dir + " has an nfo in a subdirectory"
- else:
- print dir + " is missing sfv and has an nfo in a subdirectory"
- else:
- if foundSfv == 1:
- print dir + " is missing an nfo"
- else:
- print dir + " is missing both nfo and sfv"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement