I am trying to write a script to rename a batch of computer files.
The format of the files can appear in the following ways.
Title_Title2_Title3_ABCD0123_Title4.doc
Title title2 DEFG5678 Title3 Title4.doc
XYZA1234-Title.doc
The one constant that I am interested in the file is highlighted in bold. I want to be able capture those details which are always in the following format of 4 letters and 4 numbers then rename the file and move four letters and numbers to the end of the files title.
Almost one command but I had to use tr first to get rid of the underscore because it's seen as part of the word in the first line. Darn. What it does is grep the line for a word that consists of capital letters (4) and numbers (4). -o displays only the match and not the whole line.
Thanks guys
I tried Ygors code first and that worked a treat.
It only broke when it encountered a file that had multiple periods but this was something I didn't specify in my example and those were easy to manually fix.