ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Chop off extra junk in file names

(1/3) > >>

nkormanik:

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]
.

jgpaiva:
I am not running windows, so I can't really program something to fully solve your problem.
I can, however, give you a matching regex that should do it:

--- ---^(_[^_]+_[^_]+_[^_]+_).*.png$and the replace pattern should be:

--- ---$1.pngDepending on the program you use, "$1" could also be "\1" and some of the special characters such as "()+[]" may require escaping such as "\(" instead of "(".
The example I gave should work for the first google hit for "regex renamer" which actually looks pretty neat (even though I've never tried it).

skwire:
My favourite renamer is ReNamer found here: http://www.den4b.com/?x=products&product=renamer

1) Download and run.
2) Add the files/folders you want.
3) Add a RegEx rule like this:

Chop off extra junk in file names

4) You should see the preview change to this:

Chop off extra junk in file names

If you can't tell from the screenshot what the RegEx pattern is, here you go: (_.*)_.*

skwire:
jgpaiva, nice find, that RegexRenamer.  Nick, if you choose to go with that application, here's a screenshot to help you along:

Chop off extra junk in file names

MilesAhead:
jgpaiva, nice find, that RegexRenamer.  Nick, if you choose to go with that application, here's a screenshot to help you along:
 (see attachment in previous post)
-skwire (June 20, 2012, 07:44 PM)
--- End quote ---

That does look interesting. I'm going to try it out myself.

Navigation

[0] Message Index

[#] Next page

Go to full version