def unique_filename(path):

    base, ext = os.path.splitext(path)
    counter = 0
    while os.path.exists(path):
        counter += 1
        path = base + ("(%d)" % counter) + ext

    return path
Returns a unique path by appending (n) for some number n to the end of the filename.
dataset/ETHPy150Open Sage-Bionetworks/synapsePythonClient/synapseclient/utils.py/unique_filename