def remove_excess_folders(music_f, usb_f): for item in usb_f: if item.replace(usb_path, music_path) not in music_f: statistics[3] += 1 ml.print_red("Removing " + item) if not DEBUG: call(['rm', '-r', item])
def create_missing_folders(music_f, usb_f): for item in music_f: dest = item.replace(music_path, usb_path) if dest not in usb_f: statistics[2] += 1 ml.print_green('Creating ' + dest) if not DEBUG: call(['mkdir', dest]) #print("M: " + item) #print("D:" + dest) subfolders_m = glob(item + '/*') subfolders_d = glob(dest + '/*') for sub in subfolders_m: tras = sub.replace(music_path, usb_path) #print("---> " + sub) #print(subfolders_m) if tras not in subfolders_d: ml.print_red("Should be creating " + tras) statistics[2] += 1 if not DEBUG: call(['mkdir', tras])
def remove_old_mp3(music_mp3, music_m4a, usb_mp3): for item in usb_mp3: if item.replace(usb_path, music_path) not in music_mp3: s = item.replace(usb_path, music_path) s = s[:len(s) - 3] + 'm4a' if s not in music_m4a: statistics[1] += 1 ml.print_red('Removing ' + item) if not DEBUG: call(['rm', item])
def print_statistics(): flag = 1 for i in statistics: if i == 1: flag = 0 if flag == 1: ml.print_green('\t\t-------- NO CHANGES MADE --------') return ml.print_green('\t\tAdded\t\t\t' + str(statistics[0]) + ' songs, ' + str(statistics[2]) + ' folders') ml.print_green('\t\tConverted and added\t' + str(statistics[4]) + ' files') ml.print_red('\t\tDeleted\t\t\t' + str(statistics[1]) + ' songs, ' + str(statistics[3]) + ' folders')
# convert non mp3 files # remove not in source mp3 #music_path = '/Users/Nick/Desktop/Music/' music_path = '/Volumes/Data HD/Music/iTunes/iTunes Media/Music/' usb_path2 = '/Volumes/NO_NAME/Music/' # phone usb_path1 = '/Volumes/SANDISK/Music/' # Car USB choice = int( input("Please select destination:\n1) Car USB " + usb_path1 + "\n2) Phone " + usb_path2 + "\n")) if choice == 1: usb_path = usb_path1 elif choice == 2: usb_path = usb_path2 else: ml.print_red("Invalid option!\n Exiting...") exit() # 0 1 2 3 4 #statistics = [added_songs, deleted_songs, added_folders, deleted_folders, converted_files] statistics = [0, 0, 0, 0, 0] excluded_folders = [music_path + 'Hans Zimmer', music_path + 'Marconi Union'] def main(): ml.print_green('Hola! Starting Program...') music_f = glob(music_path + '*') usb_f = glob(usb_path + '*') music_f = remove_unwanted(music_f, excluded_folders)