Another little problem has come up....
I'm generating a bunch of contour plot images in a statistics program. The resulting plot images are supposed to be named according to the script of commands as such:
_50501_22004_22404_.png
_50501_22004_22403_.png
_50501_22004_22402_.png
_50501_22004a_22401_.png
_50501_22004_22306_.png
_50501_22004_22305_.png
_50501_22004_22304_.png
_50501_22004_22303_.png
_50501_22004_22302b_.png
_50501_22004_22301_.png
I've deliberately set up this naming approach because of the problem I'm about the describe.
For some crazy reason the program creating the plot images adds numbers to the ends of the names:
_50501_22004_22404_3000.png
_50501_22004_22403_3001.png
_50501_22004_22402_3002.png
_50501_22004a_22401_3003.png
_50501_22004_22306_3004.png
_50501_22004_22305_3005.png
_50501_22004_22304_3006.png
_50501_22004_22303_3007.png
_50501_22004_22302b_3008.png
_50501_22004_22301_3009.png
I would like the original names, or, rather, the names as they were intended to be.
One solution to the problem is to create a batch file:
ren _50501_22004_22404_3000.png _50501_22004_22404_.png
etc.
The total number of files is in the tens of thousands. Over repeated times. I believe all the underlying names are unique (no repeats).
I'm wondering if any of you can come up with a better approach than creating a basic batch file to chop off that extra junk after the third underline character, but, of course, before the file name extension.
Or, chop junk BETWEEN third underline character and period of the file extension.
Some of you might come up with a magic RegEx solution? Please then suggest, too, a RegEx program.
Or maybe one of you will create a small program to do the trick? Hopefully generalizable so that others can use the program for their specific needs.
Not sure. If no better solution than the creating basic batch file approach, I'll have to continue using that.
Thanks much!
Nicholas Kormanik
[email protected].