Using python to generate a bat script of repetitive lines of code that differ in some way but can sort out a group of audio files according to their common names
The problem was…
I had a bunch of files which after decompressing were not sorted in thier folders as i expected them to be
I also could not create a folder for each group of audio files and move each group of files into thier respective
- I knew how to move one file using the command line
- But I did not know how to fully use batch scripting to move all files at once.
- I also knew how to use python to generate any file I want as it
is just a matter of using the right filename extension.
- So, I worte a python script that generated a batch script that contained the
commands needed to move all the files into their respective folder groups.
What the script does…
- the script generates a list of all the names of audio files I needed to sort
- Then, for each filename the script attaches the batch command needed to:
- first create a folder with the current filename and
- move all files with that name into the folder.
The script generated is not generic and can not be used for other audio files
Here’s a quick demo of how it worked