I have directory and it has multiple sub directories and all these sub directories contains many files. i want to move all these files to one different directory. But after moving files i should be able to recognize which file belongs to which directory.
You can use find command to move all the files from subdirectories to a different directory and also redirect the move verbose log for future reference to find file belongs to which directory earlier.
This command find all the files(type -f) in sourcedir and move it to destdir.
sourcedir - Directory which contains all subdirectories
destdir - Destination directory where you need to move all files
move.log - The log file which stores the verbose result of move command
As already said by RudiC solutions to similar questions already exist on this forum many times over, including a thread started by yourself, so please search for them.
In what way did the code suggested by RudiC in post #5 in your thread not do exactly what you requested as the 1st half of your problem? Given that suggestion, can't you try to derive a way to perform the reverse operation on your own? If you show us that you have made an honest effort to try to solve your problem, you're much more likely to get help completing it.
If you just treat this site as your unpaid programming staff, you're much less likely to get help.