Article 59GYG Renaming filename with another part of the filename

Renaming filename with another part of the filename

by
iicapn
from LinuxQuestions.org on (#59GYG)
I've been trying to find a way to do this, but I googling it is difficult because people want simple string replacements. I'm looking to move parts of a filename around... Let me explain. I have files in directory like this:

01-2015.pdf
01-2016.pdf
01-2017.pdf
01-2018.pdf
02-2015.pdf
02-2016.pdf
02-2017.pdf
02-2018.pdf
...

I want those filenames to be like this:
2015-01.pdf
2016-01.pdf
2017-01.pdf
2018-01.pdf
2015-02.pdf
2016-02.pdf
2017-02.pdf
2018-02.pdf
...

The closest I've come is a blog post (http://www.peteryu.ca/tutorials/shel...n_the_filename)

So I tried something like this:

Code:ls -1 | awk '{print("mv "$1 " " $1)}' | sed 's|d{2}-|-d{4}{$1}|2' > rename.txtBut I'm not quite there...

If anyone could help me, thank you so much!!!latest?d=yIl2AUoC8zA latest?i=t6p3Gx3WNJo:NvzRNQtlbc4:F7zBnMy latest?i=t6p3Gx3WNJo:NvzRNQtlbc4:V_sGLiP latest?d=qj6IDK7rITs latest?i=t6p3Gx3WNJo:NvzRNQtlbc4:gIN9vFwt6p3Gx3WNJo
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments