How can I copy or move folders with file manager-style conflict prompts?

November 12, 2026 4 answers
Asked by Trizza

I want to merge folder contents, prompt when files conflict, and show their sizes and modification times before deciding whether to overwrite. This would also help when resuming an interrupted copy or move.

Can existing tools handle this, or would a script need to check each file and prompt before transferring it?

Answers

Roffy

For a simpler prompt, try cp -i for copying or mv -i for moving. Add the recursive option when copying a directory, and check the manual for your system because options and behavior can vary.

That won't give you the full file manager prompt. A recursive copy can merge existing directories without asking about each directory, and the file overwrite prompt doesn't normally compare sizes or modification times.

Zazzy:

Shell aliases can make the interactive options convenient, but don't rely on an alias inside a script. Put the option in the command itself.

Reply to this answer
ink..adjacent

Rsync is useful if you can review a batch of changes rather than approve every conflict individually. A dry run such as rsync --dry-run --itemize-changes source/ destination/ shows what it would transfer without doing it.

The trailing slash on source matters: it copies the contents of that directory into the destination. Review the output before running it without --dry-run. This is a preview, not an interactive overwrite prompt with a size and date comparison for each file.

Trizza:

So that's handy for reviewing a resume, but not quite the per-file choice I'm looking for.

Reply to this answer
EXTRA-WIDE_is-fine

For the exact prompt, a wrapper is probably the way to go. Walk the source tree and map each relative path to the destination. If both paths are files, use stat to display their sizes and modification times, then ask whether to replace or skip. Copy new files without prompting if that's the behavior you want.

You'll also need decisions for a file conflicting with a directory, symbolic links, permissions and errors. Size and modification time are useful clues, not proof that contents match. Handle filenames safely, including spaces and newlines, and don't parse ordinary line-based file listings.

For a move, remove a source file only after its copy succeeds. Leave skipped or failed files in place, and remove source directories only when they're empty. Test on disposable folders first, especially around interruptions and existing destination files.

Reply to this answer
anti-clockwise+sometimes

You don't necessarily need a separate rsync process for every file. A script could collect the user's decisions first and then transfer the approved paths in a batch. The tradeoff is that the preview and the actual transfer happen at different times, so files may change in between.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions