Does Python have any built-in functionality to add a number to a filename if it already exists?
My idea is that it would work the way certain OS\'s work - if a file
I ended up writing my own simple function for this. Primitive, but gets the job done:
def uniquify(path): filename, extension = os.path.splitext(path) counter = 1 while os.path.exists(path): path = filename + " (" + str(counter) + ")" + extension counter += 1 return path