def generatePaths(path, fileSystem, artistSystem): for fold in os.listdir(path): try: open(path + "/" + fold) fileSystem[path].append(path + "/" + fold) try: tag = get_info(path + "/" + fold) artistSystem[path].append(tag["artist"]) except TypeError: pass except IOError, mess: if mess[0]==13: fileSystem[path + "/" + fold] = [] artistSystem[path + "/" + fold] = [] generatePaths(path + "/" + fold,fileSystem,artistSystem) else: raise
def setSongList(songs,bands,folders): folders = [fold + "/" for fold in folders] if bands!=None and len(bands)!=0: for song in songs[:]: tag = get_info(song) for band in bands: try: if tag["artist"].lower()==band.lower(): break except IOError: break else: songs.remove(song) if folders!=None and len(folders)!=0: for song in songs[:]: for folder in folders: if folder==song[:song.rfind("/")+1]: break else: songs.remove(song) return songs
for fold in os.listdir(path): try: open(path + "/" + fold) listOfSongs.append(path + "/" + fold) except IOError, mess: if mess[0]==13: findSongs(path + "/" + fold,listOfSongs) else: raise return listOfSongs audacityPath, winampPath = load() sourceFold = raw_input("Please enter the folder containing the audio files: ") destFold = raw_input("Please enter the folder you wish for the converted files to be put in: ") destFold = destFold.replace("\\","/") checkDest(destFold) print audacity = progLoc(audacityPath,"Audacity","audacity.exe") print winamp = progLoc(winampPath,"Winamp","winamp.exe") print save(audacity,winamp) delete = raw_input("Would you like to delete each track after conversion?(y/n): ")=="y" auto = Automate(audacity,winamp) allSongs = findSongs(sourceFold) for song in allSongs: tagInfo = get_info(song) auto.automateConversion(song,destFold,tagInfo["artist"],tagInfo["title"],tagInfo["album"],tagInfo["track"],tagInfo["length"],delete)
ie "%a/%r/%t - %s." would indicate to create a folder named the same as the artist, inside that, a folder named for the album, and inside that, name the track staring with the track number, then a dash (-), follwed by the track name Note that if the specified attribute is missing, it will be omitted. string: """) move = raw_input("And finally, would you like to move the files, or just copy them? (m/c): ")=='m' songList = setSongList(dictToList(fileSystem),bandsToCopy,pathsToCopy) print songList #copy skipped = [] startTime = time.time() for song in songList: tag = get_info(song) if sort: executeFormatString(songString,song,tag,preserve) else: try: copySong(song, save + "/" + tag["artist"] + " - " + tag["title"] + ".mp3") except IOError: copySong(song, save + "/" + song[song.rfind("/")+1:]) if len(skipped)!=0: print "Unfortunately, the following files failed to copy for some reason or another:" for song in skipped: print song print "\ntime elapsed to copy all audio files: %f seconds" %(time.time()-startTime)