0

如果我在普通目录中运行它,它将起作用。使用 shutil.move 具有相同的结果。

    from os import listdir, rename
    from os.path import getmtime, isfile

    for x in match_list:
        file_location = f'{f}\\{x[0]}'
        file_destination = f'{f}{old_dir}\\{x[0]}'
        if isfile(file_location):
            if isfile(file_destination):
            dot_loc = file_destination.rfind('.')
            file_destination = f'{file_destination[:dot_loc]}(1)', f'{file_destination[dot_loc:]}'
            rename(file_location, file_destination)
        else:
            rename(file_location, file_destination)
4

0 回答 0