Need a renaming plan. Please help!

Advanced Renamer forum
#1 : 24/09-14 17:10
Noy
Noy
Posts: 3
I have images in a directory named accordingly;

A151946_101_12.jpg
A151946_201_12.jpg
A151946_A01_12.jpg
F1298393_501_83.jpg
F1298393_F01_83.jpg
F1298393_E01_83.jpg

Everything [before] the first under-score ( _ ) may be 7 or 8 characters. But I would like to remove everything [after] that the first under-score, and then apply an increment. To produce the following results

A151946_01.jpg
A151946_02.jpg
A151946_03.jpg
F1298393_01.jpg
F1298393_02.jpg
F1298393_03.jpg

* Of course I'd like the increment to start over for prefix. Is this possible? Can someone please suggest a plan?

Thank you!

Noy Hadar


24/09-14 17:10
#2 : 25/09-14 16:07
Stefan
Stefan
Posts: 274
Reply to #1:
 
Hi.

For this we would us a JavaScript


FROM:
A151946_101_12.jpg
A151946_201_12.jpg
A151946_A01_12.jpg
F1298393_501_83.jpg
F1298393_F01_83.jpg
F1298393_E01_83.jpg

TO:
A151946_01.jpg
A151946_02.jpg
A151946_03.jpg
F1298393_01.jpg
F1298393_02.jpg
F1298393_03.jpg

RULE:
Keep first part till and including first hyphen.
Add two digits counter, reset if first part had changed.



USE JavaScript Method
(http://www.advancedrenamer.com/user_guide/metho d_script)

-----------------8<---------------------- CODE:

if(index < 1) vLastName='xxx';
//will match (A151946_) and (101_12) out of "A151946_101_12.jpg"
vNewName= item.name.replace(/(.+?_).+/, '$1');
if(vNewName!=vLastName) vCounter=0;
vLastName=vNewName;
vCounter++; vCounter=('000'+vCounter).slice(-2);
return vNewName+vCounter;

/CODE ----------------->8----------------------



 



25/09-14 16:07
#3 : 04/10-14 00:08
Noy
Noy
Posts: 3
Reply to #2:

Stefan, thank you so much for this code!!! I look forward to trying it. I'll raise any questions if I have any. :)

Noy Hadar


04/10-14 00:08
#4 : 04/10-14 01:21
Noy
Noy
Posts: 3
Reply to #2:

You ROCK man!! Worked like a charm. You saved my @ss!! Thanks so much! :)


04/10-14 01:21
#5 : 04/10-14 14:39
Stefan
Stefan
Posts: 274
Reply to #4:
 
Thanks for the feedback!

Fine it works for you, Noy.




 


If this tool had saved you time, perhaps you want to donate an Dollar to Kim?
See http://www.advancedrenamer.com/ >>> [Donate] button.


04/10-14 14:39