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

how can I copy all files, with different extensions, from several different subdirectories, into one main folder?

share|improve this question

If you're not wanting to keep the directory structure and just want to move all the files into one folder, you can do something like this.

find /src/folder/1 /src/folder/2 -type f -exec cp {} /path/to/destination/ \;

This will find every file -type f from the given source folders, then execute the -exec command on them. In this case, you want to copy cp them into the destination folder.

Keep in mind, this will fully traverse the source folders recursively. If you want to only go deep a certain level into the source directories, use the -maxdepth options on the find command.

find /src/folder/1 /src/folder/2 -type f -maxdepth 2 -exec cp {} /path/to/destination/ \;
share|improve this answer
find ./ -type f -exec cp '{}' ./ \;
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.