stemplayer demucs renaming album script wip

I'm too dumb to use github, so I'll be pasting my work-in-progress Python scripts here.
I don't really know Python terribly well, I just type stuff into Bing and see what it tells me.

This script is a utility that renames splits generated by DEMUCS, for copying onto the Kanye/Kano Stemplayer. It renames the files correctly and also the folders so they are ordered.

TO DO: generate track file per folder with formatting, prompt for song bpm (maybe) and also album file for the main folder. Perhaps also rename some variables so they're clearer.

key functions here to note:

os.path.join

os.rename

.iterdir()

format

 

import os
from pathlib import Path

path=Path(r"c:\temp\franzFerdinand")
num=1
for dirs in path.iterdir():
    print(dirs.name)
    files_in_path=dirs.iterdir()
    for item in files_in_path:
        file_path=os.path.join(path,dirs.name,item.name)
        print (file_path)
        file_pa=os.path.join(path,dirs.name)
        if item.name=="bass.wav":
            os.rename(file_pa+"\\"+item.name,file_pa+"\\"+item.name.replace("bass","3"))
        elif item.name=="drums.wav":
            os.rename(file_pa+"\\"+item.name,file_pa+"\\"+item.name.replace("drums","4"))
        elif item.name=="other.wav":
            os.rename(file_pa+"\\"+item.name,file_pa+"\\"+item.name.replace("other","1"))    
        elif item.name=="vocals.wav":
            os.rename(file_pa+"\\"+item.name,file_pa+"\\"+item.name.replace("vocals","2"))
    newDirName="T"+format(num)
    newDirPath=os.path.join(path,newDirName)
    print (newDirName)
    print (newDirPath)
    os.rename(file_pa,newDirPath)
    num+=1

Comments

Popular posts from this blog

script update wip 2