以下是一个简单的Bash脚本,可以自动将不同的子文件夹压缩并将它们存储到带有日期命名的文件夹中:
#!/bin/bash
# Set the directory path to the parent folder containing the subfolders to be zipped
SOURCE="/path/to/parent/folder/"
# Set the name of the destination folder
DESTINATION="/path/to/destination/folder"
# Set the current date as part of the destination folder name
DATE=$(date +%Y-%m-%d)
# Create the destination folder if it doesn't exist
mkdir -p "$DESTINATION/$DATE"
# Loop through each subfolder in the source directory and create a zip file using its name
for folder in "$SOURCE"*/; do
folder=${folder%*/}
zip -r "$DESTINATION/$DATE/${folder##*/}.zip" "$folder"
done
在此脚本中,您需要设置源目录(包含要压缩的子文件夹的父文件夹路径)和目标目录(带有日期命名的压缩文件将存储在其中)。随后,在循环中遍历源目录中的每个子文件夹,并为其创建一个zip文件,其名称基于子文件夹的名称。最后,执行此脚本将自动将所有子文件夹压缩并将它们存储到目标文件夹中,文件夹名称基于创建压缩文件的日期。