Conflict Resolution
What happens when a file you're moving already exists in the destination folder? forg provides three powerful ways to handle these collisions.
You can specify the conflict resolution mode using the --on-conflict (or -c) flag.
1. Skip (Default)
The safest option. If a file with the same name exists in the destination, forg will skip the move and report it in the execution summary.
forg Downloads --on-conflict skip
2. Replace
Use this if you want to overwrite the existing file. However, forg still prioritizes safety by creating a .bak backup of the original file in the destination before replacing it.
One-Generation Backup
The replace mode implements a destructive-backup strategy. If a .bak file already exists for the target filename, it is deleted before the current destination file is rotated into the backup slot. Only the most recent version is preserved as a backup.
forg Downloads --on-conflict replace
Example: If image.png exists in ~/Pictures, forg will:
- Rename the existing
~/Pictures/image.pngto~/Pictures/image.png.bak. - Move the new
image.pngfromDownloadsto~/Pictures.
3. Versioned
This is perfect for keeping multiple versions of the same file. forg will automatically increment a version number in the filename.
forg Downloads --on-conflict versioned
Logic:
- If
report.pdfexists, the new file becomesreport_v1.pdf. - If
report_v1.pdfalso exists, it becomesreport_v2.pdf. - And so on.
Dry Run Support
All conflict resolution modes are fully supported in --dry-run. You will see exactly how a file would be renamed or if it would be skipped before any changes are made.