20 lines
609 B
Bash
20 lines
609 B
Bash
#!/bin/bash
|
|
|
|
WATCH_DIR="/home/wuyingwen/ai_projects/ComfyUI/output"
|
|
TARGET_DIR="/home/wuyingwen/ai_projects/ComfyUI/workflows"
|
|
|
|
inotifywait -m -e close_write --format "%w%f" "$WATCH_DIR" | while read file; do
|
|
if [[ "$file" == *.json ]]; then
|
|
# 提取原始文件名
|
|
base_name=$(basename "$file")
|
|
|
|
# 生成时间戳 + 原始文件名,避免重复覆盖
|
|
timestamp=$(date +"%Y%m%d_%H%M%S")
|
|
new_name="${timestamp}_${base_name}"
|
|
|
|
# 拷贝文件
|
|
cp "$file" "$TARGET_DIR/$new_name"
|
|
echo "✅ 检测到 $file,已复制为 $new_name"
|
|
fi
|
|
done
|