how to rename files recursively, only keeping last x digits plus extension
sorry if this has been answered (directly or indirectly) before, but I'm not really a programmer and after reading a lot of threads and man pages today with still no luck, I guess it's time to ask.
My problem is this:
I have a number of directories, all containing files of different name lenghts, including letters, numbers and possibly spaces. I want to recursively rename all of these files, so that only the _last_ 5 digits (not counting the extension) remain. In other words: I want to cut off all but the last 5 digits and not touch the extension.
I've tried to read up on tr, rename (perl version), sed, cut etc. and browsed through some threads here, but so far couldn't quite figure out how to do it.
If someone could point me to the right (standard) CLI tools and syntax, I'd heavily appreciate it! Thank you!
Last edited by furryspider; 11-29-2009 at 02:03 PM.
Reason: set the solved prefix