That could also be a job for a regular expression.
Capture up to 7 symbols, then have an optional single symbol, then capture a literal dot and up to three more characters. Then rename the file to 'A' . $1 . $2
The last step is to realize that things have gone horribly wrong with your requirements as stated, when you notice that you are not guaranteed to have unique filenames after losing the last letter, and files start conflicting with each other.
|
|---|