def rotate(paths):
    for _ in range(len(paths)):
        path = paths.pop()
        (prefix, _, suffix) = os.path.basename(path).partition('.')
        suffix = str((int((suffix or 0)) + 1))
        rotated = os.path.join(os.path.dirname(path), ((prefix + '.') + suffix))
        os.rename(path, rotated)
        paths.insert(0, rotated)
def rotate(paths):
    for _ in range(len(paths)):
        path = paths.pop()
        (prefix, _, suffix) = os.path.basename(path).partition('.')
        suffix = str((int((suffix or 0)) + 1))
        rotated = os.path.join(os.path.dirname(path), ((prefix + '.') + suffix))
        os.rename(path, rotated)
        paths.insert(0, rotated)