This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Rename filenames in perl using regex

I would like to replace a bunch of filenames from-

"MY.switch.Org.1st"
"router.2nd.Org.MY"

to, something like as following with all uppercase-

"1ST.SWITCH.MY.ORG"
"2ND.ROUTER.MY.ORG"

Any suggestion will be greatly appreciate.....

perl;

Hello kekdge!

We believe that this post does not fit the main topic of this site.

This isn't even remotely bioinformatics related (though Phil's reply is interesting).

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Maybe you meant to go to stackoverflow.com?

1 answer

perl -e 's/.[^\.]*$/rename $_, uc($`) . $&/e for @ARGV' *

Change the * if you only want to do this to .txt files to *.txt etc... (found here)

Does that really work!?

I am getting the output as following-

rename MY.switch.Org.1st.txt, MY.switch.Org.1st.txt
rename router.2nd.Org.MY.txt, router.2nd.Org.MY.txt

I am looking for -

1ST.SWITCH.MY.ORG.TXT
2ND.ROUTER.MY.ORG.TXT

Please do not answer obviously off-topic questions.

Log in to answer this question.