Qi28 commited on
Commit
752a58a
·
verified ·
1 Parent(s): 6a9db3c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +14 -1
main.py CHANGED
@@ -132,7 +132,20 @@ def download_openi(datasets):
132
  os.system(f'unzip -j {os.path.join(save_path, file_name)} -d {extract_path}')
133
  else:
134
  os.system(f'7z x {os.path.join(save_path, file_name)} -o{extract_path} -aoa')
135
- print(f"数据集 {file_name} 已解压到 {extract_path} 目录。")
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  # 删除压缩包文件
138
  os.remove(os.path.join(save_path, file_name))
 
132
  os.system(f'unzip -j {os.path.join(save_path, file_name)} -d {extract_path}')
133
  else:
134
  os.system(f'7z x {os.path.join(save_path, file_name)} -o{extract_path} -aoa')
135
+
136
+ # 将解压后的文件移动到指定的路径
137
+ for root, dirs, files in os.walk(extract_path):
138
+ for file in files:
139
+ src_path = os.path.join(root, file)
140
+ dst_path = os.path.join(save_path, file)
141
+ shutil.move(src_path, dst_path)
142
+ for dir in dirs:
143
+ src_path = os.path.join(root, dir)
144
+ dst_path = os.path.join(save_path, dir)
145
+ shutil.move(src_path, dst_path)
146
+ # 删除解压后创建的文件夹
147
+ shutil.rmtree(extract_path)
148
+ print(f"数据集 {file_name} 已解压到 {save_path} 目录。")
149
 
150
  # 删除压缩包文件
151
  os.remove(os.path.join(save_path, file_name))