I have a sort of folders (A,B,C,D,E,F,G,H) and I have one file in every folder has the same name in all the folders (file.txt) but the size of this file is different from folder to folder. I wanted to copy this file from every folder into a new folder (X) and give the file the same name of it is original folder. I used this bach script to copy the files:
#!/bin/bash
insub_FIM_M_1=path to a parent folder conatin all the folders (A,B,C,D,E,F,G,H)
for i in $(cat $insub_FIM_M_1/FIM_1.txt); do
cp insub_FIM_M_1/${i} <path to the new folder X >
done
In this code all the files will ovewrite in the new folder (X) because they have the same name inside the folders. How can I revise this code to add the folder name to the file name so I can know the source of the file.