Command-Line – How to Bulk Move Files Up One Directory Safely

command linerename

How can I move files up a directory where there might be hundreds or thousands of files in the directory, and you might not be sure about whether there are dupes in ... What method would you use?

How to handle dupes will vary, sometimes we'll overwrite, sometimes we need to be safer. IO can be important because these are production servers. But given quantity a prompt for non duplicate files isn't an option. Preservation of permissions, and timestamps, etc, is important. We usually won't know what the data is.

Oh and it using mv isn't required, rsync, cp solutions welcome.

note: we're running CentOS 5.5 so let me know if it won't work there due to it being a more recent… feature

Best Answer

I would recommend using rsync from the parent:

rsync -avPr -b --suffix='-original' child/* .

which will backup all existing duplicate files in parent to file-original.

Related Question