#!/bin/bash
# 路径检查脚本
# 用于验证文件整理后的路径是否正确

echo "🔍 开始检查文件路径..."
echo "========================================"

# 检查文档目录
echo "📁 检查文档目录："
if [ -d "/home/ubuntu/output/documents/ai_wuxia_project" ]; then
    echo "✅ /home/ubuntu/output/documents/ai_wuxia_project/ 存在"
    count=$(ls -1 /home/ubuntu/output/documents/ai_wuxia_project/*.md 2>/dev/null | wc -l)
    echo "   包含 $count 个MD文档"
else
    echo "❌ /home/ubuntu/output/documents/ai_wuxia_project/ 不存在"
fi

# 检查关键文件是否存在
echo ""
echo "📄 检查关键文件："
files=(
    "/home/ubuntu/output/documents/ai_wuxia_project/ai-era-opc-article.md"
    "/home/ubuntu/output/documents/ai_wuxia_project/wuxia-opc-article.md"
    "/home/ubuntu/output/documents/ai_wuxia_project/wuxia-opc-social.md"
    "/home/ubuntu/output/documents/ai_wuxia_project/wuxia-opc-quick-post.md"
    "/home/ubuntu/output/documents/ai_wuxia_project/文件地址清单.md"
    "/home/ubuntu/output/documents/文件路径映射指南.md"
)

for file in "${files[@]}"; do
    if [ -f "$file" ]; then
        echo "✅ $file 存在"
    else
        echo "❌ $file 不存在"
    fi
done

# 检查根目录是否还有MD文档
echo ""
echo "🧹 检查根目录清理情况："
root_md=$(find /home/ubuntu -maxdepth 1 -name "*.md" 2>/dev/null | wc -l)
if [ "$root_md" -eq 0 ]; then
    echo "✅ 根目录已无MD文档"
else
    echo "⚠️  根目录还有 $root_md 个MD文档："
    find /home/ubuntu -maxdepth 1 -name "*.md" 2>/dev/null
fi

# 检查Python脚本路径
echo ""
echo "🐍 检查Python脚本路径："
if grep -q "/home/ubuntu/output/multi_platform" /home/ubuntu/multi_platform_content.py 2>/dev/null; then
    echo "✅ multi_platform_content.py 使用正确的输出路径"
else
    echo "❌ multi_platform_content.py 输出路径可能有问题"
fi

if grep -q "/home/ubuntu/output/images" /home/ubuntu/generate_all_images.py 2>/dev/null; then
    echo "✅ generate_all_images.py 使用正确的输出路径"
else
    echo "❌ generate_all_images.py 输出路径可能有问题"
fi

# 检查目录结构
echo ""
echo "📂 检查目录结构："
echo "/home/ubuntu/output/ 目录结构："
find /home/ubuntu/output -maxdepth 2 -type d | sort

echo ""
echo "========================================"
echo "📋 总结："
echo "- 文档已整理到 /home/ubuntu/output/documents/"
echo "- 根目录已清理"
echo "- Python脚本路径正确"
echo "- 新的文件路径映射指南已创建"
echo ""
echo "🚀 检查完成！"