Question: renames files with the same folder name
0
gravatar for Bioinfosenhaji
5 months ago by
France/Marseille
Bioinfosenhaji20 wrote:

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

assembly rename • 145 views
ADD COMMENTlink modified 5 months ago • written 5 months ago by Bioinfosenhaji20

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:

101010 Button

ADD REPLYlink written 5 months ago by lieven.sterck8.7k

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.

ADD REPLYlink written 5 months ago by lieven.sterck8.7k

All right, thank you very much for the information.

ADD REPLYlink written 4 months ago by Bioinfosenhaji20
0
gravatar for cpad0112
5 months ago by
cpad011214k
India
cpad011214k wrote:

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
ADD COMMENTlink modified 5 months ago • written 5 months ago by cpad011214k

Thank you very much. I'll try you.

ADD REPLYlink written 4 months ago by Bioinfosenhaji20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1082 users visited in the last hour