【问题标题】:How can I copy .out files to the new folder from a folder including 120 subfolders which also including 120 subfolders? (by using Python, Bash or R )如何将 .out 文件从包括 120 个子文件夹的文件夹中复制到新文件夹中,其中还包括 120 个子文件夹? (通过使用 Python、Bash 或 R)
【发布时间】:2022-01-22 10:12:57
【问题描述】:

我尝试使用 os.walk(),但是,我不知道如何从子文件夹的子文件夹中获取文件。

【问题讨论】:

  • 请添加到您的问题(不发表评论):您搜索了什么,找到了什么?您尝试过什么,它是如何失败的?

标签: python bash


【解决方案1】:

你可以试试这样的:

import pathlib
import shutil

data_dir = 'your/path'
output_dir = 'output/dir'

for filename in pathlib.Path(data_dir).glob('**/*.out'):
    shutil.move(filename, output_dir)

Bashfind your/path -iname '*.out' | xargs -i{} mv {} output/dir

【讨论】:

    猜你喜欢
    • 2017-07-05
    • 2015-12-26
    • 1970-01-01
    • 2016-10-25
    • 2012-08-08
    • 2017-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多