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