Folder Sync and Comparison
Sync files between folders, compare differences, and keep content consistent
Overview
When working on multiple devices or locations, keeping folders synchronized is important. Claude can help you compare differences between two folders, intelligently sync files, ensure consistent content, and avoid the tedious manual copy-paste process.
Use Cases
- Sync projects between work computer and home computer
- Sync local folders with external hard drive
- Compare if backups are complete
- Keep multiple working directories consistent
Steps
Step 1: Compare Folder Differences
First, analyze what's different between the two folders.
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
Step 2: Generate Sync Plan
Generate a detailed sync plan based on the differences.
Based on the above differences, please generate a sync plan:
- List of files to copy from source to target
- List of files to copy from target to source (for bidirectional sync)
- Handling recommendations for conflicting files (modified on both sides)
- Estimated time and space needed for sync
Let me confirm before executing
Step 3: Execute One-Way Sync
Sync source folder content to the target.
Please 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
Step 4: Bidirectional Sync
Keep both folders completely consistent.
Please execute bidirectional sync:
- Source: ~/Documents/Work
- Target: /Volumes/Backup/Work
- Newer files overwrite older files
- For conflicting files (both updated), keep both versions with suffixes
- Delete files that one side has deleted
- Generate sync report when complete
Step 5: Set Up Monitoring Sync
Create a script to periodically check and sync.
Please create a monitoring script:
1. Check ~/Documents/ActiveProject for changes every hour
2. If there are new or modified files, automatically sync to /Volumes/Backup/ActiveProject
3. Send notification with sync results
4. Save to ~/watch_sync.sh and set up auto-run
Warning: Bidirectional sync may cause accidental file deletion or overwriting. Always backup important data before first sync! It's recommended to use --dry-run mode first to see what operations will be performed.
Tip: Using rsync's -avh parameters shows detailed progress. Adding --exclude can exclude files that don't need syncing, like .DS_Store, node_modules, etc.
Common Questions
Q: How do I handle sync conflicts? A: Options include: 1) Keep the newer file; 2) Keep both versions with renaming; 3) Manually choose which to keep. Claude will mark conflicting files for your decision.
Q: Can I exclude certain files from syncing? A: Yes. Use the --exclude parameter to exclude specific files or folders, like "exclude .git and node_modules folders".
Q: What's the difference between sync and backup? A: Sync is bidirectional, keeping both sides consistent; backup is one-way, preserving historical versions. For important data, it's recommended to use a dedicated backup solution rather than simple sync.