renaming files and including folder/directory name in it
0
0
Entering edit mode
10 weeks ago
arshad1292 ▴ 70

Hello,

I have 500 folders and each folder contains about 5 files. I want to rename those files and include folder name with it.

For example:

My folders (sample1_1, sample2_2, sample3_3) look like this:

sample1_1: bin.1.permissive.fa bin2.orig.fa

sample2_2: bin.1.permissive.fa bin2.orig.fa

sample3_3: bin.1.permissive.fa bin2.orig.fa

Now, I want to rename in a way that files look like this:

sample1_1: sample1_bin.1.fa sample1_bin2.fa

In other words, I the following 2 things to be changed:

  1. Include folder name in the file but after removing last part of it.
  2. Remove middle part of the file i.e. permissive, orig etc.

Any linux expert here please help me in writing the script.

Many thanks in advance!

rename loop mv • 253 views
ADD COMMENT
0
Entering edit mode

Can not install this... was able to download the tar file but can not run tar -zxvf *.tar.gz as it gives following error:

tar: brename: Cannot open: File exists
tar: Exiting with failure status due to previous errors
ADD REPLY

Login before adding your answer.

Traffic: 1344 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6