Created
October 23, 2024 15:10
-
-
Save yknext/5ae3c5f75f367206909dd95287cd2db8 to your computer and use it in GitHub Desktop.
mv_photo.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 将hash方式存放的相册如immich,重新整理为年月 | |
# 定义源文件夹和目标根文件夹 | |
SOURCE_DIR="2ce01bb6-e13d-46e5-b1ae-4e60f2d1c79c" | |
TARGET_DIR="./" | |
# 遍历源文件夹下的所有文件 | |
find "$SOURCE_DIR" -type f | while read -r file; do | |
# 获取文件的创建日期 | |
creation_date=$(stat -f %B "$file") | |
# 格式化日期为年和月 | |
year=$(date -r "$creation_date" +%Y) | |
month=$(date -r "$creation_date" +%m) | |
# 创建目标文件夹 | |
mkdir -p "$TARGET_DIR/$year/$month" | |
# 移动文件到目标文件夹 | |
mv "$file" "$TARGET_DIR/$year/$month/" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment