Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 102 directories that I would like to merge into a single directory. If there are conflicts I would like to use the most recent file.

How can I do this?

Previously I've tried searching for the folders then copying them into the same parent directory, since the directories I want to merge have the same name it asks if I want to merge them. However it doesn't have an option to automatically keep the most recent file.

share|improve this question
You can try to write a bash script to do it, I think nautilus isn't smart enought to do something like this. – Evandro Silva Oct 16 '12 at 12:35

You can do it with a command line :

find orig/ -type f  -exec cp -u -a \{\} dest/ \;

where orig is the directory containing the stuff you want to flatten and copy, and dest your destination directory. So what this will do is:

  1. find each file in orig/ and its sub-directories
  2. for each file, call copy (cp) to dest with the following options: u mean update, ie only copy if the file in newer, a archive, ie keep attributes, among them the dates of creation / modification

Small test here worked, but of course, be careful, and be sure to have a backup in case :-)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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