Night_Wood

MoviesOrganizer

Jan 15th, 2016
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. import os;
  2.  
  3. raw_input('Press ENTER to scan for movies and covers...');
  4.  
  5. # Identifies which files don't line up with a cover
  6.  
  7. def printList(list):
  8.     for i in range(0, len(list)):
  9.         print '\t' + str(i+1) + '\t', list[i];
  10.        
  11. def parseFilename(filename):
  12.     for i in range(len(filename)-1, 0, -1):
  13.         if filename[i] == '.':
  14.             return filename[0:i];
  15.     return 'null';
  16.  
  17. movies = os.listdir('E:\\1. Movies');
  18. covers = os.listdir('E:\\1. Movies\\Covers');
  19. missingCoversList = [];
  20. extraCoversList = [];
  21. missingYearsList = [];
  22. mval = 0; cval = 0;
  23. errors = 0;
  24.  
  25. while mval < len(movies):
  26.     mov = movies[mval];
  27.     if mov == 'Covers':
  28.         mval += 1;
  29.         mov = movies[mval];
  30.     movTitle = parseFilename(mov);
  31.     if movTitle[len(movTitle)-1:len(movTitle)] != ')' or movTitle[len(movTitle)-6:len(movTitle)-5] != '(':
  32.         missingYearsList.append(movTitle);
  33.         #print '\nTitle Error:',movTitle,'is missing the year\n';
  34.         errors += 1;
  35.     else:
  36.         movTitle = movTitle[0:len(movTitle)-7];
  37.     cov = covers[cval];
  38.     if cov == 'Thumbs.db':
  39.         cval += 1;
  40.         cov = covers[cval];
  41.     covTitle = parseFilename(cov);
  42.     if movTitle.lower() == covTitle.lower():
  43.         #print mov,'matches',cov;
  44.         cval += 1;
  45.         mval += 1;
  46.     else:
  47.         #print '\nMatch Error:\t',mov,'\n\t\t',cov,'\n';
  48.         errors += 1;
  49.         if movTitle.lower() < covTitle.lower():
  50.             mval += 1;
  51.             missingCoversList.append(movTitle);
  52.         else:
  53.             cval += 1;
  54.             extraCoversList.append(covTitle);
  55.            
  56. print '\nMatches:',str(len(movies)-errors) + '/' + str(len(movies));
  57. print 'Errors:',errors;
  58. print 'Missing covers:',len(missingCoversList);
  59. printList(missingCoversList);
  60. print 'Extra covers:',len(extraCoversList);
  61. printList(extraCoversList);
  62. print 'Movies missing years:',len(missingYearsList);
  63. printList(missingYearsList);
  64.  
  65. raw_input();
Add Comment
Please, Sign In to add comment