Thursday, October 22, 2015

linux - Rename and reverse the numbering of a list of files

In Linux, preferably using bash, what would be the best way to achieve the goal below?


Say I have a series of numbered files


001.png, 002.png, 003.png

What is the best way to move/rename them to be in the reverse order?


Bonus points: I have a series of 1500 files, I would actually like to reverse the order of ever second block of 40. Note the letters are not part of the name. I use them to indicate the uniqueness of the content.


001a, 002b, ..., 040c <- leave as is
041a, 042b, ..., 080c <- reverse order of these files
081a, 082b, ..., 120c <- leave as is
121a, 122b, ..., 160a <- reverse order of these files

becomes:


001a, 002b, ..., 040c
041c, 042b, ..., 080a
081a, 082b, ..., 120c
121c, 122b, ..., 160a

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...