Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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
add comment
find ./ -type f -exec cp '{}' ./ \;
share|improve this answer
add comment

Your Answer

 
discard

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.