Let's say, under this directory: /home/data/
There are 100 folders, the name of these folders are 24538_7#1, 24538_7#2, 24538_7#3 ... to 24538_7#384.
In each folder, there are many files and folders.
The names of the desired file in each folder is Aligned.out.sam
The desired folder for renamed files is /home/SAM
How can I copy all these files to the new folder(/home/SAM) and rename them properly as 24538_7#1.sam, 24538_7#2.sam, 24538_7#3.sam ......?
I tried doing it by the command below but it didn't work:
mv /home/data/*/Aligned.out.sam /home/SAM/*.sam
1 Answer
Something along the lines of
for sam in */Aligned.out.sam; do \ name=$(basename $(dirname "$sam")) \ cp "$sam" "/home/SAM/$name.sam" \
donemight do the trick
3