📁 文件管理 📖 官方

文件夹同步与对比

在不同位置的文件夹之间同步文件,对比差异,保持内容一致

★★☆ 中级 10-15 min 2025年1月12日
📋

使用场景

💬

提示词

Please compare the differences between these two folders:
- Source: ~/Documents/Projects
- Target: /Volumes/USB/Projects
Show:
- Files that only exist in the source folder
- Files that only exist in the target folder
- Files that exist in both but have different content (determined by modification time or checksum)
- Summary of total count and total size

Then execute one-way sync:
- From ~/Documents/Projects to /Volumes/USB/Projects
- Only copy new and updated files
- Keep extra files in the target folder (don't delete)
- Show sync progress and completed file count
- Log sync activity to ~/sync_log.txt

预期结果

💡

使用技巧

  • 使用 rsync 的 -avh 参数可以显示详细进度。添加 --exclude 可以排除不需要同步的文件,如 .DS_Store、node_modules 等。