Hi BK,
welcome.
kasthuri wrote:Hi all I have a series of filenames like the following:
Tile_r3-c3_w12_st01_sec01.tif
The images are taken as a montage of a single optical plan (r3-c3 meaning row 3 column 3 of the montage). They are also multiple sections that correspond to 'z levels'. st01_sec01 means that this montage is taken from strip 01 section 01. The next montage z level would then be st01_sec02. There are ~ 9 sections per strip and then a new strip is started but continues down in z (i.e. st01_sec09 is a 'higher' level than st02_sec01). Each strip is on a wafer that extends in Z as well. (i.e. all of the strips from wafer 12 (w12 above) are higher in z than all the sections from wafer 13). thus, *.w11_st09_sec09 comes just 'before' *.w12_st01_sec01 . I would like to take a sequence like the above and rename it from
Tile_r3-c3_w12_st01_sec01.tif to Tile_Z{zzz}_Y{yyy}_X{xxx}.tif
where Z(zzz) is an absolute number extracted from w*_st*_sec* and Y{yyy} and X{xxx} are rows and columns respectively. I have given a more concrete example below (this assumes that I am starting the z -numbering from w12 but that is not necessarily the case
Tile_r3-c3_w12_st01_sec01.tif Tile_Z{001}_Y{003}_X{003}.tif
Tile_r3-c2_w12_st01_sec01.tif Tile_Z{001}_Y{002}_X{003}.tif
Tile_r3-c1_w12_st01_sec01.tif Tile_Z{001}_Y{001}_X{003}.tif
Tile_r2-c3_w12_st01_sec01.tif Tile_Z{001}_Y{003}_X{002}.tif
Tile_r2-c2_w12_st01_sec01.tif Tile_Z{001}_Y{002}_X{002}.tif
Tile_r2-c1_w12_st01_sec01.tif Tile_Z{001}_Y{001}_X{002}.tif
Tile_r1-c3_w12_st01_sec01.tif Tile_Z{001}_Y{003}_X{001}.tif
Tile_r1-c2_w12_st01_sec01.tif Tile_Z{001}_Y{002}_X{001}.tif
Tile_r1-c1_w12_st01_sec01.tif Tile_Z{001}_Y{001}_X{001}.tif
Tile_r3-c3_w12_st01_sec02.tif Tile_Z{002}_Y{003}_X{003}.tif
Tile_r3-c2_w12_st01_sec02.tif Tile_Z{002}_Y{002}_X{003}.tif
Tile_r3-c1_w12_st01_sec02.tif Tile_Z{002}_Y{001}_X{003}.tif
Tile_r2-c3_w12_st01_sec02.tif Tile_Z{002}_Y{003}_X{002}.tif
Tile_r2-c2_w12_st01_sec02.tif Tile_Z{002}_Y{002}_X{002}.tif
Tile_r2-c1_w12_st01_sec02.tif Tile_Z{001}_Y{001}_X{002}.tif
Etc. I have over 2000 files that need to be renamed this way and I am way lost! Any help (and as always soon
would be greatly appreciated.
Thanks
BK
I didn't read all of this, i just show you an example, hopping it is right.
Test this with an few test files first.
Depending on your examples:
FROM:
Tile_r
3-c
3_w12_st01_sec
01.tif to
TO:
Tile_Z{"sec
01"}_Y{"c
3"}_X{"r
3"}.tif
dropping "_w12_st01_"
FROM:
Tile_r3-c3_w12_st01_sec01
TO:
Tile_Z{001}_Y{003}_X{003}
Do:
RegEx(1)
Search: (.+_)r(\d)-c(\d)_w12_st01_sec(\d\d)
Replac: \1Z{0\4}_Y{00\3}_X{00\2}
Explanation:
for
Tile_r3-c3_w12_st01_sec01
the regex
(.+_)r(\d)-c(\d)_w12_st01_sec(\d\d)
means:
(.+_) >> match one-or-more of any sign till next expression "r" >>>> will match "Tile_" and is grouped
       in group (...) one, which can be accessed by \1 in the replacement.
r(\d) >> match literally "r" followed by one digit and group the regex with (...) parentheses to match the digit , which match the "3" and can be reused by \2
-c(\d) >> match an dash followed by "c", then match one digit in an third group, this "3" can be accessed by \3 in replacement
_w12_st01_ >> match "_w12_st01_" literally , don't group them since we doesn't need them in replacement
sec(\d\d) >> match "sec" followed by two digits, you can use \4 in Replace to access what is matched by this regex \d\d which give you here "01".
(i see now i didn't had needed to group () this "Tile_" too, ... but anyway... it doesn't hurts... so let it be
)
Then compose your replacement string "\1Z{0\4}_Y{00\3}_X{00\2}"
by using the back reference meta chars "\n" where "n" is the number of the wanted (...)-group from the left.
\1 holds "Tile_"
\2 holds "3"
\3 holds "3" too in this example
\4 holds here "01"
So the replacement (new name) is build like that:
\1 Â + Â "Z{0" Â + Â \4 Â + Â "}_Y{00" Â + Â \3 Â + Â "}_X{00" Â + Â \2 Â + Â "}"
in short: "\1Z{0\4}_Y{00\3}_X{00\2}"
HTH?
If yes: please help two others too.
General Note:
Always don't trust me! Test with test files first!
My solution depends on the quality of your examples.
The term "RegEx" describes an technique as that (Regular Expressions) and an used expression (like ".+") itself.
In BRU select a few files in the "Name" column to see changes on the "New Name" column.
If i had used "quotes", then don't use them for real, they are only for explanation.
If i had used ~ signs exchange them each by an space/blank.
At the end we build the new name by using that what is matched by the regex inside the parentheses, and build that way our New Name.
That what is matched in Search by the regex in the first (...) parentheses, can be accessed In Replacement by using "\1", and second (...) by \2,...
See this two oldest posts in the Regular Expressions sub-forum for an RegEx syntax overview:
=> Getting Started: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=5
=> Go ahead: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=27
And BTW:
BK> "newbie needs help with complicated rename function"
That's clear, that's normal, that's why you post here, you don't have to use this as subject.
Please think about an better title and modify your post accordingly.
Like "Renaming by moving part" or reorder of parts in file name or like that.