I need to move all the text files from /abc/d1 to /abc/d2, but files need to be renamed if /abc/d2 has files with the same name already.

cd /abc/d1

mv *txt /abc/d2

closed as unclear what you're asking by RalfFriedl, G-Man, user34720, GAD3R, Mr Shunz Mar 19 at 10:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


rsync can do this with the --backup flag, but it renames the preexisting file in the target location. You can specify how it renames with further options.

-b, --backup
With this option, preexisting destination files are renamed as each file is transferred or deleted. You can control where the backup file goes and what (if any) suffix gets appended using the --backup-dir and --suffix options.

Make sure you thoroughly review the options and flags of rsync to ensure you don't clobber or delete any important files/data.

Not the answer you're looking for? Browse other questions tagged or ask your own question.