File size: 1,249 Bytes
bf48c38 5d2e8bb d67c45e bf48c38 d67c45e 5d2e8bb bf48c38 5d2e8bb d67c45e 5d2e8bb d67c45e 5d2e8bb d67c45e 5d2e8bb d67c45e 5d2e8bb d67c45e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#!/usr/bin/env sh
######################################################################
# @author : xic (zeexoc@outlook.com)
# @file : tar
# @created : Saturday Nov 02, 2024 18:06:32 CST
#
# @description : tar datas
######################################################################
subdirs=("train" "test")
source_dir='source' # 源目录
data_dir='data' # data目录
rm -r $data_dir
mkdir $data_dir
# 遍历 train 和 test 目录
for subdir in "${subdirs[@]}"; do
# 获取子目录下的所有文件夹
cp -r $source_dir/$subdir $data_dir/$subdir
folders=$(find "$data_dir/$subdir" -mindepth 1 -maxdepth 1 -type d)
for folder in $folders; do
folder_name=$(basename "$folder")
# 设置标签
if [ "$folder_name" == "nailong" ]; then
label=1
else
label=0
fi
echo "处理文件夹: $folder_name, 标签: $label"
# 执行 Python 脚本
#python ./convert2PNG.py "$folder"/*
python ./generate_info.py "label=$label" "$folder"/*
# 压缩文件夹并删除原文件夹
tar -cf "$data_dir/$subdir/$folder_name.tar" -C "$folder" . && rm -rf "$folder"
done
done
|