Super User is a question and answer site for computer enthusiasts and power users. 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 500 folders of templates in one folder. Now each folder has file called template_thumbnail.png . now i want something so that all those files get copied to one folder with name same as the home folder name

is it possible

I have cygwin installed and i can copy that folder in there so basically it will linux shell script

share|improve this question
up vote 1 down vote accepted
for DIR in *; { if [ -d "${DIR}" ]; then cp "${DIR}/template_thumbnail.png" "${DIR}.png"; fi; }

That takes each entry in the current directory and checks it's a directory. If it is it copies the dirname/template_thumbnail.png to dirname.png.

share|improve this answer
Note he said "copied" not "moved", so "cp" would be better than "mv". – Wes Hardaker Apr 20 '11 at 13:36
Oops - my bad - edited – Majenko Apr 20 '11 at 13:46
is it possible that it also searches for file in sub folders as well , because some of my png files are in further subfolders – Moorage Apr 20 '11 at 14:13
Now you're getting more complex... You'll have to do some trickery with the find command for that. – Majenko Apr 20 '11 at 14:15
yes u r right , thanks buddy , i will try that – Moorage Apr 20 '11 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .