Thank you very much. I'll try you.
• 0 views
•
link
Hello, in short, I have folders and in each folder there is a file 'call < configs.fasta > and I wanted to get how I can rename the files with the same folder name. I've tried a for loop but it doesn't work.
for i in *; do mv /*/contigs.fasta $i.fasta; done
Thank you for helping me
input:
$ find . -maxdepth 2 -mindepth 2 -type f -name "contigs.fa"
./test2/contigs.fa
./test1/contigs.fa
dry-run
$ parallel --dry-run cp {} {//}.fa ::: $(find . -maxdepth 2 -mindepth 2 -type f -name "contigs.fa")
cp ./test2/contigs.fa ./test2.fa
cp ./test1/contigs.fa ./test1.fa
with bash:
tree .
.
├── test1
│ └── contigs.fa
└── test2
└── contigs.fa
dry-run (remove echo):
$ find . -maxdepth 1 -mindepth 1 -type d | while read line; do echo mv $line/contigs.fasta $i.fasta; done
or
$ for i in $(ls -d */); do echo mv ${i%%/}/contigs.fasta ${i%%/}.fasta; done
mv ./test2/contigs.fasta test2.fasta
mv ./test1/contigs.fasta test2.fasta
Thank you very much. I'll try you.
Log in to answer this question.
A small educational note: I added (code) markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:
I understand why you might mask out the path your working in but i'm afraid the cause of your issue is likely caused by what's 'under' the * .
otherwise you can add in a dummy folder but at least we can then see what you try to do.
All right, thank you very much for the information.