[Tutor] automatic output file naming scheme

kevin parks kp8 at mac.com
Sun Mar 28 17:44:24 CEST 2010


okay. I got the subprocess bit to work and i have os walk doing its walk. But now for something i did not think about until i started to think about how to fit these two bits to work together.

os walk is going to traverse my dirs from some given starting point and process files that it finds that fit my criteria. So i my case it will look for all sound files in a given directly structure and then call sox and do a conversion. This part i can already probably do just by combining the working code that i have … but now i need to have some kind of automagic naming scheme that creates an output file name that is based on the input name but is unique, either adding a number or suffix before the file extension, or even a time stamp. Since we want to create file names that are unique and not clobber existing files, but also will tells us something meaningful about how the file was created so that finding:

foo01.aif or foo.1.aif would yield something like foo-out01.aif or foo01-out.aif or something similar.

How can you do such a thing in python? is there some elegant way to take the input file name and combine it with some other string to create the output file name?

-kp




More information about the Tutor mailing list