Finding And Moving Specific Strings In Subfolders Only

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Finding And Moving Specific Strings In Subfolders Only

Postby LouieChuckyMerry » Mon May 10, 2010 12:12 pm

Hello, and thanks in advance to anyone willing to help; I really appreciate it. I have thousands of .mp3 files in thousands of album folders in hundreds of artist folders in a music folder that have the following structure:

C:\MUSIC\ARTIST.ALPHA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.ALPHA\AlbumName2[xxxx]
C:\MUSIC\ARTIST.BETA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName2[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName3[xxxx]

where "xxxx" is the specific album's release year. All of the .mp3 files are labeled to my specifications but, an epiphany later, I've decided that I want to move the "[xxxx]" from the end of the album's folder name to it's beginning so that the albums are listed within the "ARTIST" folders by release year instead of alphabetically. No problem: Bulk Rename Utility--"Move/Copy (6)"--to the rescue! However, I've encountered 2 issues that a couple of hours with the program and searching the forums haven't been able to solve. First, is there a way to only rename the last subfolders in the file path so that I can batch rename the "MUSIC" folder instead of having to batch rename hundreds of "ARTIST" folders? That is, when I open the "MUSIC" folder in Bulk Rename Utility and tick "Folders" and "Subfolders" in "Selections (12)" a batch rename includes both the "ARTIST" folders and the "ALBUM" folders. Basically, do I need to manually deselect the hundreds of "ARTIST" folders before renaming, or is there an easier way to only rename the "ALBUM" folders? Second, roughly 1 in 30 of the albums are labeled

C:\MUSIC\ARTIST\AlbumName[xxxx][.flac]

where "[xxxx]" is still the release year and "[.flac]" tells me that the files inside the folder aren't .mp3's but instead are, er, in the .flac format. Of course, the original batch renaming by moving the last 6 characters of the album's folder name to it's beginning is a problem for this small-percentage of folders. So, before batch renaming all of the "ALBUM" folders I would like to move any instance of the string "[.flac]" from the end of the album's folder name to it's beginning. Is this possible with BRU? I get the gist of strings, but I couldn't find where to manipulate them in the program's user interface, let alone make this occur. Anyway, if you've actually read all of this then thanks again; and, if you've actually read all of this and plan on posting a reply then thank you extra-very much.
LouieChuckyMerry
 
Posts: 4
Joined: Mon May 10, 2010 10:26 am

Re: Finding And Moving Specific Strings In Subfolders Only

Postby Stefan » Mon May 10, 2010 9:22 pm

LouieChuckyMerry wrote:Hello, and thanks in advance to anyone willing to help; I really appreciate it. I have thousands of .mp3 files in thousands of album folders in hundreds of artist folders in a music folder that have the following structure:

C:\MUSIC\ARTIST.ALPHA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.ALPHA\AlbumName2[xxxx]
C:\MUSIC\ARTIST.BETA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName1[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName2[xxxx]
C:\MUSIC\ARTIST.GAMMA\AlbumName3[xxxx]

where "xxxx" is the specific album's release year. All of the .mp3 files are labeled to my specifications but, an epiphany later, I've decided that I want to move the "[xxxx]" from the end of the album's folder name to it's beginning so that the albums are listed within the "ARTIST" folders by release year instead of alphabetically. No problem: Bulk Rename Utility--"Move/Copy (6)"--to the rescue! However, I've encountered 2 issues that a couple of hours with the program and searching the forums haven't been able to solve. First, is there a way to only rename the last subfolders in the file path so that I can batch rename the "MUSIC" folder instead of having to batch rename hundreds of "ARTIST" folders? That is, when I open the "MUSIC" folder in Bulk Rename Utility and tick "Folders" and "Subfolders" in "Selections (12)" a batch rename includes both the "ARTIST" folders and the "ALBUM" folders. Basically, do I need to manually deselect the hundreds of "ARTIST" folders before renaming, or is there an easier way to only rename the "ALBUM" folders? Second, roughly 1 in 30 of the albums are labeled

C:\MUSIC\ARTIST\AlbumName[xxxx][.flac]

where "[xxxx]" is still the release year and "[.flac]" tells me that the files inside the folder aren't .mp3's but instead are, er, in the .flac format. Of course, the original batch renaming by moving the last 6 characters of the album's folder name to it's beginning is a problem for this small-percentage of folders. So, before batch renaming all of the "ALBUM" folders I would like to move any instance of the string "[.flac]" from the end of the album's folder name to it's beginning. Is this possible with BRU? I get the gist of strings, but I couldn't find where to manipulate them in the program's user interface, let alone make this occur. Anyway, if you've actually read all of this then thanks again; and, if you've actually read all of this and plan on posting a reply then thank you extra-very much.


Hi, welcome.
You can't say "work on last sub-folder only". At least i don't know how at the moment.
But this is not necessary actual, if the name of your last sub-folder differs from the Artist folder name in a way it can be matched by using of RegEx pattern.




First i need to check your real folder names!
Questions:

* ARTIST folders have NOT 4 digits like the AlbumName?

* AlbumName have ONLY 4 digits for the year?
So AlbumName has NO digit before the four digits of the year like this example:
C:\MUSIC\ARTIST.ALPHA\AlbumName1[xxxx]

Or are they really enclosed with [...] ?, what would be good, because then it's more easy to match with regex.

In short: the AlbumNames must have something common to match what is not seen in the ARTIST name.

At the end i just have to know to provide an good regex!






Then we could try:

FROM:
C:\MUSIC\ARTIST\AlbumName[xxxx][.flac]
TO:
C:\MUSIC\ARTIST\[xxxx]AlbumName[.flac]

Un-check Options > Ignore... > Folder Extensions

Selection(12)
[X] Folders
[ ] Files
[X] Subfolders

RegEx(1)
Match: (.+)(\[\d\d\d\d\])
Repla: \2 - \1

Image

NOTE: test ONLY with some copy of your real files and folders! I don't know if my solution will work for your folder structure.
And before i can give the real solution i need to see real folder names, and you have to check out the Questions above and tell me the answers.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Finding And Moving Specific Strings In Subfolders Only

Postby LouieChuckyMerry » Tue May 11, 2010 3:11 am

Stefan: thank you very much for taking the time to help. Before answering your questions, I need to clarify one thing. I have a test "MUSIC" folder that I'm using to experiment with BRU; it has the exact structure as I posted above. HOWEVER, in my original, much larger "MUSIC" folder the structure is exactly the same as above except that all release years are in "{xxxx}" form and not "[xxxx]" form. To explain: as I began playing with BRU a few days ago, the first thing that I did was replace all "{" with "[" and all "}" with "]" and, thinking that I would eventually do this to my original "MUSIC" folder as well, I posted as above. Now, after reading your kind reply, I see that perhaps having the album's release year in "{xxxx}" form might be helpful, as it is always 4 digits and always the only use of "{" and "}" in the AlbumName or ARTIST. I'm very sorry for the confusion, but I honestly thought that I was making things easier :oops: . Now, to answer your questions,

1) ARTIST folders do not have 4 digits like the album name. Never.

2) AlbumName do have ONLY 4 digits for the year, and always in "{xxxx}" form.

3) Occasionally an AlbumName will have a digit (or 2 or 3 or whatever) before the 4 digits of the year; it depends on the name of the album and the artist. For example, the 2006 studio album "10,000 Days" by the artist "Tool", in .mp3 format, would have the structure

C:\MUSIC\TOOL\10,000Days{2006}

while the 2004 studio album "Time" by the artist "7 For 4", in .flac format, would have the structure

C:\MUSIC\7.For.4\Time{2004}[.flac]

and the 1974 live album "You Can't Do That On Stage Anymore, Vol. 2 (The Helsinki Concert)" by Frank Zappa, in .flac format, would have the structure

C:\MUSIC\FRANK.ZAPPA\YouCan'tDoThatOnStageAnymore,Vol.2(TheHelsinkiConcert)[Live]{1974}[.flac]

Also, so you know, artist names are always all capitol letters and separated by "." and album names never have spaces between the words or characters, and, straight brackets "[" and "]" ALWAYS enclose "Live" and ".flac", exactly as in the above 3 examples (that is, "[.flac]" isn't an actual file extension but simply a label).


Now that you've given me a better understanding of how RegEx works, and the fact that the albums' release years are a constant 4 digits in the unique (to the file path) form "{xxxx}", it seems to me that your original suggestion could be slightly modified and then work perfectly. Of course, my head might explode trying to figure it out, but I reckon that that wouldn't be such a big loss! Seriously, I get the basic idea of RegEx but don't fully understand it's "language," so I'm not exactly sure how to modify your original suggestion. I'll experiment on my test "MUSIC" folder, but I'd surely welcome another more knowledgable reply from you. And thank you again.
LouieChuckyMerry
 
Posts: 4
Joined: Mon May 10, 2010 10:26 am

Re: Finding And Moving Specific Strings In Subfolders Only

Postby Stefan » Tue May 11, 2010 8:46 am

Great Louie. Good maintained structure and post.

BTW, for 3) i meant "other digits right before those 4 digits of the year", but since the year
is clearly enclose in {...} brackets already, it's pretty fine.

So i understood we have to match the following:

FROM:
C:\MUSIC\7.For.4\Time{2004}[.flac]
1) A few of every signs till right before an "{"-sign, here "Time"
2) "{" followed by four digits followed by "}", here "{2004}"
3) a few of every signs, or not, here "[.flac]"


So to match 1) we use the regex "(.+)" which means: search (or better: match) one-or-more of any sign, which should match "Time" here.
The (...) parentheses means: hold what is matched by the regex inside of the (...) for later reuse by an "\n" symbol,
where "n" is the occurrence from the left of the regex string. So "\1" will give us back what is matched by the regex in the first (...) group.

(BTW: regex means "Regular Expressions" and is an technic to match part of string by special pattern, and regex means also the expression itself)

To match 2) we use "( \{ \d \d \d \d \d \} )" without the spaces and the quotes, they are for explanation only.
Explanation:
(...) you know already now.
\{ and \} means: search for { } literally , since { and } are regex meta signs and have an special meaning, so we have to escape them by an leading \
\d means: match one single digit. Since we search for four digits i use \d\d\d\d
We could use smtg like \d{4} to say match exactly four digits, like (\{\d{4}\}) where you can see the use of the meta signs { } in an regex too :wink:
Anyway, 2) will match here "{2004}"

to match 3) we use the regex (.*) which means: match none-or-more of any sign.
So, if there is none after the {year} it's fine for us, and if there is smtg, it's fine too.
(Note: for 3) we could really search for "[.flac]" itself, but i make it just shorter and more general)

Then in the replacement we just reorder the matched groups by exchanging \1 and \2: \2\1\3





So you may try this regex:

RegEx(1)
Search: (.+)(\{\d\d\d\d\})(.*)
or
Search: (.+)(\{\d{4}\})(.*)
or
Search: (.+)(\{\d\d\d\d\})(\[\.flac\])
(since the dot . and the [ ] are meta signs too, we have to escape them too by \ )

For replacement use:
Repla: \2\1\3
or
Repla: \2 \1\3
or
Repla: \2 - \1\3
Just to give you an idea.


Note: quotes " " are for explanations only, don't use them in the regex.


-------- Settings -----------------
Selection(12)
[X] Folders
[ ] Files
[X] Subfolders
------------------------------------




HTH? :D
I hope i have nothing overseen?

See the both oldest posts in the regex sub-forum for more regex explanations and the syntax list.




See an picture how this works for me:
Image
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Finding And Moving Specific Strings In Subfolders Only

Postby LouieChuckyMerry » Tue May 11, 2010 12:30 pm

Stefan! Thank you so so much for taking the time to help. Your explanation of the RegEx was brilliant. I'd played with some of the ideas in your first post earlier but had a few problems; then, after reading your second post--the splitting of the original file name into parts under "Match" and then the rearrangement of these parts under "Replace"--I actually understand. Mind you, I won't be giving tutorials on BRU any time soon, but I feel confident enough to manipulate my own "MUSIC" folder. And, more thanks for the extra effort showing examples of how to "Replace" the parts with changes (spaces, "-", anything else). That was one of my main questions, and now understanding this opens a whole new world of possibilities. Anyway, thank you very much for taking the time to help me; I really do appreciate it.
LouieChuckyMerry
 
Posts: 4
Joined: Mon May 10, 2010 10:26 am


Return to BRU Support


cron