0xZohar commited on
Commit
8f31ebf
·
verified ·
1 Parent(s): 6bdb904

Add code/cube3d/render/draft.py

Browse files
Files changed (1) hide show
  1. code/cube3d/render/draft.py +46 -0
code/cube3d/render/draft.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+
4
+ # 目标目录(你想要将所有文件移动到的目录)
5
+ destination_dir = '/public/home/wangshuo/gap/assembly/data/car_1k/subset/ldr' # 替换为目标路径
6
+
7
+ # 根目录,包含所有相对路径的文件所在的基础目录
8
+ root_dir = '/public/home/wangshuo/gap/assembly/data/car_1k' # 替换为你的根目录路径
9
+
10
+ # 确保目标目录存在
11
+ if not os.path.exists(destination_dir):
12
+ os.makedirs(destination_dir)
13
+
14
+ # 文件列表 TXT 路径
15
+ file_list_path = '/public/home/wangshuo/gap/assembly/data/car_1k/subset/optimal_ldr_subset.txt' # 替换为你的 TXT 文件路径
16
+
17
+ # 打开并读取文件列表
18
+ with open(file_list_path, 'r') as f:
19
+ for line in f:
20
+ # 去掉每行的空格和换行符
21
+ relative_path = line.strip()
22
+
23
+ # 跳过空行
24
+ if not relative_path:
25
+ continue
26
+
27
+ # 获取绝对路径
28
+ file_path = os.path.join(root_dir, relative_path)
29
+
30
+ # 检查源文件是否存在
31
+ if os.path.exists(file_path):
32
+ # 获取目标文件的完整路径(保留文件名)
33
+ dest_file = os.path.join(destination_dir, os.path.basename(file_path))
34
+
35
+ # 如果目标文件已经存在,可以选择覆盖或者跳过
36
+ if os.path.exists(dest_file):
37
+ print(f"文件 {file_path} 已经存在于目标目录,跳过复制")
38
+ continue
39
+
40
+ # 移动文件到目标目录
41
+ shutil.copy(file_path, dest_file)
42
+ print(f"已将 {file_path} 复制到 {dest_file}")
43
+ else:
44
+ print(f"源文件 {file_path} 不存在,跳过")
45
+
46
+ print("所有文件已处理完成!")