run.py 982 Bytes
Newer Older
Zheng Gaoshan's avatar
Zheng Gaoshan committed
1
2
3
import os
import shutil

5-19-3's avatar
5-19-3 committed
4
####5-19-3
Zheng Gaoshan's avatar
Zheng Gaoshan committed
5
6
7
8
9


def main():


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    # 定义初始路径和目标路径
    source_dir = '/workspace/input/'
    target_dir = '/workspace/output/'

    # 确保源路径存在
    if not os.path.exists(source_dir):
        print(f"错误:源路径 {source_dir} 不存在。")
    else:
        # 创建目标路径(如果不存在)
        os.makedirs(target_dir, exist_ok=True)

        # 获取源路径下的所有文件(不递归子目录)
        for file_name in os.listdir(source_dir):
            source_file = os.path.join(source_dir, file_name)
            target_file = os.path.join(target_dir, file_name)

            # 只拷贝文件,忽略子目录
            if os.path.isfile(source_file):
                shutil.copy2(source_file, target_file)  # copy2 保留元数据(如修改时间)
                print(f"已拷贝: {source_file} -> {target_file}")

        print("拷贝完成。")
Zheng Gaoshan's avatar
Zheng Gaoshan committed
32
33
34

if __name__ == '__main__':
    main()