-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetdata.py
22 lines (19 loc) · 992 Bytes
/
getdata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import shutil
oridatadir = '/workspace/share/kitreg/data/scene_classify/kitchen'
targetdatadir = '/workspace/share/beit3/data/kitchen'
# 创建目标文件夹
os.makedirs(targetdatadir, exist_ok=True)
# 循环遍历oridatadir下的所有文件夹
for foldername in os.listdir(oridatadir):
folderpath = os.path.join(oridatadir, foldername)
if os.path.isdir(folderpath):
print(f'Processing folder: {folderpath}')
# 遍历train、val、test三个文件夹
for subfoldername in os.listdir(folderpath):
subfolderpath = os.path.join(folderpath, subfoldername)
if os.path.isdir(subfolderpath):
# 将subfolderpath下的所有文件和子文件夹复制到targetdatadir下
targetsubfolderpath = os.path.join(targetdatadir, subfoldername)
shutil.copytree(subfolderpath, targetsubfolderpath, dirs_exist_ok=True)
print(f'Copied {subfolderpath} to {targetsubfolderpath}')