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

link|improve this question

69% accept rate
feedback

1 Answer

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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