Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

It sounds like a simple question but if it was I wouldn't be asking it. I can obviously do this by opening all the folders in nautilus and pasting each one individually but the computer is the robot not me (I'm talking about 500 files).

So is there a way of doing this more efficently by gui or command line? either is as good as the other.

If it makes you feel better you will be saving a poor "V" key from severe punishment.

share|improve this question
up vote 6 down vote accepted

If the folders are in the same folder that the file exists, then use:

for dir in *; do [ -d "$dir" ] && cp YOURFILE.EXT "$dir" ; done

In other scenery, if the file is in a different path, use:

for i in folder1 folder2 folder3 folder4; do cp YOURFILE.EXT $i; done

If you don't know what exactly are the names of the folders where to put the file, try:

There is no need to make a script. Simply drop these commands in a terminal and check the results.


YOURFILE.EXT = The name of your file, may contain the full path.
folder1 folder[...] = the name of the folders where to drop the file,
-- folder names may contain the full path.
share|improve this answer
Why exactly shouldn't we comment on your answer? – Adam Byrtek Mar 23 '11 at 10:18
Feel free to post your comments, but if you have a better solution, then your suggestions are not for me but the owner of the question. If you check in my previous answers, many people have said something like: "my solution is better" and down vote my suggestion, but they don't dare to drop their solution in an answer whose behavior leads to just a confrontation (which I don't face indeed) and don't lead to the obtaining of a good solution. – Geppettvs D'Constanzo Mar 23 '11 at 16:15
Thanks Geppettvs the first command was the winner just a note for others it wont work over samba you would need to replace the cp with gvfs-copy – Allan Mar 23 '11 at 19:27
Don't worry too much about that, if your solution is good then it will be upvoted/accepted, like in this case. Sometimes a comment can improve the solution, you don't have to treat them as a personal attack. – Adam Byrtek Mar 23 '11 at 21:59

I can make touch {jan,feb,mar}-{Rep.xls,graph.xls} makes feb-graph.xls jan-Rep.xls feb-Rep.xls mar-graph.xls jan-graph.xls mar-Rep.xls
But i cant open them. So i wanted to make one file 1.ods saved from OO-Calc and then wanted to cp it similar like touch {jan,feb,mar}-{Rep.xls,graph.xls} using cp 1.ods {jan,feb,mar}{Rep.ods,graph.ods} but that doesnt work. cp: target `margraph.ods' is not a directory SO im also interested in this

share|improve this answer

find . -type d | xargs -I{} cp ./myfile {}/

This is how I got the job done.

Here was the problem I wanted solved. I wanted to test all my new virtual hosts before installing the actual applications.

find . -type d
find . -type d | xargs -I{} cp ./ {}/ 
ls ./*




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.