Regular Expression Needed, Please


I need it to rename one hundred sequentially numbered albums. Notice that in the following examples the number format is not exactly the same all over.

Current Name
My File Vol. 001
My File Vol. 2
My File Vol. 03
My File Vol. 004
... up to My File Vol. 100

The new sequentially numbered album names should look like this:

New Name
My File Vol. 001^100
My File Vol. 002^100
My File Vol. 003^100
My File Vol. 004^100
... up to My File Vol. 100^100

You will have noticed that it is only the numbered portion of the album name that needs to be changed.

Thank you for your help.

Make sure your files are sorted like they are in ascending order like above.

Begin Action Group _Script Test#TEST

Action #1 Actiontype 5: Format value Field ______: TITLE Formatstring: $regexp(%title%,'(.+?vol\.)\s*\d+$',$1 $num(%_counter%,3)'^'%_total_files%,1)

End Action Group _Script Test#TEST (1 Action)


"My File Vol. 001" ->

"My File Vol. 001^5"

"My File Vol. 2" ->
"My File Vol. 002^5"

"My File Vol. 03" ->
"My File Vol. 003^5"

"My File Vol. 004" ->
"My File Vol. 004^5"

"My File Vol. 100" ->
"My File Vol. 005^5"

As You can see it keeps the text before the no and the counts the files then places a '^' and then a total file count to top it off.

As you can see this will work no matter if you have a 100 or 25 files. You don't need to go changing it every time a different situation arises.

Thank you stevehero, for the effort you have put into figuring this out. Forgive me though, as the use of regular expressions (regex) is absolutely foreign to me and when I applied your regex it did not deliver the results I expected. Undoubtedly though, this was due to my own inability to correctly, or clearly, express my predicament to start off with. On top of this, I was most probably also applying it wrongly.

I realize now that I need to be much more careful when I describe where and what it is I need the regex to do. For instance, it is 100 albums that I need to renumber - each of which may contain any number of files. I thought I could easily adapt your supplied regex by changing some of the parameters in your format string before applying it again, but I only kept on shooting myself in the foot. It was/is great fun, however. :slight_smile:

In the end, I gave up, and I certainly would appreciate a prod in the right direction.

Thanks again.

All you need to change is the field to ALBUM and in the format string change %title% to %album% while keeping the rest of the string.

Make sure to sort the album column by clicking the title of the column making sure they are sorted in ascending order with vol 1 being at the top.

Select all files (ctrl + A) and apply the action.

Thanks, stevehero.

Sad to report that impatience completely messed up the renaming for me. While I should have waited for your response, I opted to fool around - which I did pretty good and ended up with the mess. Now I seem to have only two options left: do it the long way or start afresh, but this time with the ALBUM field completely blank. What I still do have to start with, is the album-directory/folder already correctly named (e.g. My Album Vol. 001^100 up to My Album Vol. 100^100), but how do I transfer that to the album field, using a regular expression?

Please have a read of the FAQs. (HERE) Particularly this section. (HERE)

Begin Action Group _Script Test#TEST

Action #1 Actiontype 5: Format value Field ______: TITLE Formatstring: %_directory%

End Action Group _Script Test#TEST (1 Action)

Thank you.