Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! python
- import os
- # This script checks you have a mp4 file in the Plex Versions/Original Quality folder. If you do it moves the other version in that directory.
- # Make sure to drop this file in the directory with all your folders of movies and then run python filename.py in terminal from that directory
- maxAmount = 1 # Set this for how many you want to move over
- archiveDir = '_todelete/' # Set this to the directoy name you want the files moved to
- checkDir = "Original Quality" # I use original quality for the converted files. If you use another type put the directory name from Plex Versions/ in here
- directorySplit = '/' # For running on Windows filesystem
- i = 0
- def currentFiles(path):
- global i, maxAmount, archiveDir, directorySplit
- for root, dirs, files in os.walk(str(path)):
- path1 = root.split(directorySplit)
- for file in files:
- if "Original Quality" not in path1 and (".mp4" in file or ".mkv" in file or ".m4v" in file or ".avi" in file or ".wmv" in file):
- filepath = directorySplit.join(path1)+file
- if not os.path.exists(archiveDir):
- os.makedirs(archiveDir)
- print ("Moved "+filepath+" --> "+archiveDir+file) #if Python 3
- #print "Moved "+filepath+" --> "+archiveDir+file #if Python 2
- if os.path.exists(filepath):
- os.rename(filepath, archiveDir+file)
- i = i + 1
- def runCheck():
- global archiveDir, checkDir, maxAmount, i, directorySplit
- for root, dirs, files in os.walk("."):
- path = root.split(directorySplit)
- for file in files:
- if checkDir in path and ".mp4" in file:
- if i < maxAmount:
- currentFiles(str(path[0]+directorySplit+path[1]+directorySplit))
- else:
- return
- return
- runCheck()
Advertisement
Add Comment
Please, Sign In to add comment