how to rename and move files according to directory names?

Posted by Shan on Ask Ubuntu See other posts from Ask Ubuntu or by Shan
Published on 2012-04-14T22:49:28Z Indexed on 2012/04/14 23:46 UTC
Read the original article Hit count: 256

Filed under:

I have bunch of directories containing the file with the same name. I want to move these files to another directory and at the same time renaming them with the directory name so that they are distinguished and are not over-written.

EDIT: All the directories are in the same directory. Destination is one directory on the system which could be anything. We read directory and read file form it and rename it exactly as the directory name and put it to the destination.

An important constraint is that the name of the file is given which will be in all of the directories. Directories might contain other files bit also the one which is given

Thanks a lot

© Ask Ubuntu or respective owner

Related posts about shell-scripting