📜  python 移动所有 txt 文件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.652000             🧑  作者: Mango

代码示例1
from pathlib import Path

src_path = '\tmp\files_to_move'

for each_file in Path(src_path).glob('*.*'): # grabs all files
    trg_path = each_file.parent.parent # gets the parent of the folder 
    each_file.rename(trg_path.joinpath(each_file.name)) # moves to parent folder.