Rearrange filename

A swapping-ground for Regular Expression syntax

Rearrange filename

Postby spaceman » Thu Feb 27, 2014 8:08 pm

Hi

I've had a look here and a play for the last half hour but can't get it to do what I want.

I have WAV files of name format:

album\artist_artist--title_title_title.nnnnnn-xx.yy.wav

Where artist_artist is the artist name, with spaces as underscores
title_title_title is the track name, with spaces as underscores
nnnnnn is a six digit reference number
xx is the track number
yy is the cd number in a set (normally 01)

for instance

album\Pharrell_Williams--Happy.66622-05.01.wav

and am trying to generate a filename:

artist -- album -- track number -- track name

I can replace underscores with spaces, I can make it lose the last 13 digits (the reference and track info) but need to move the penultimate 4th and 5th digits to before the track name. That's where I am falling over.

Any help much appreciated!

Thanks
spaceman
 
Posts: 3
Joined: Thu Feb 27, 2014 7:51 pm

#1Regex must complete before #9Append begins

Postby truth » Fri Feb 28, 2014 5:36 am

The one example only had five 'reference#'s, so I assumed it should have been six.
Since \ is an illegal filename char, its also assumed you meant Dir\Filename.wav
In that case, only #9AppendFolderName can add Album into your filenames.
The #1Regex must finish processing before #9 starts, thus it cant affect Album.

You can either run BRU twice (once for each step), or just use BRC in a batch.
BRU examples below:

Run1: Prefix album only to .wav's not already processed
#9AppendFolderName=Prefix
#9Separator=@@
#12Filter=*.wav !*@@* !*--*--*--*

Run2: Rearrange filenames (that now contain album)
#1RegexMatch=(.*)@@(.*?)--(.*)\.[0-9]{6}-(\d\d)\.\d\d$
#1RegexReplace=\2 -- \1 -- \4 -- \3
#3Replace=Underscore
#3With=Space
#12Filter=*@@*.wav

You dont need the 12Filters if you're careful with filename-selections,
but they prove helpful when working with many files/dirs at a time.
(if going this route, I'd prob save each run in a .bru settings file)

OrigName / NewName results:
C:\Despicable_Me_2\Pharrell_Williams--Happy.667622-05.01.wav
C:\Despicable_Me_2\Pharrell Williams -- Despicable Me 2 -- 05 -- Happy.wav
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Rearrange filename

Postby spaceman » Fri Feb 28, 2014 10:42 am

Thanks very much, I'll try it in a bit and report back.
spaceman
 
Posts: 3
Joined: Thu Feb 27, 2014 7:51 pm

Re: Rearrange filename

Postby spaceman » Fri Feb 28, 2014 3:47 pm

Thanks, I got it mostly working (my fault not yours!)

But with a bit of tweaking I can get it good enough every time with

(.*?)--(.*)\.[0-9]{6}-(\d\d)\.\d\d$
\1 -- \3 -- \2

Which doesn't quite do what I'd originally asked but I can then run it through some tagging software which does the rest anyway.

Thanks for the help!
spaceman
 
Posts: 3
Joined: Thu Feb 27, 2014 7:51 pm

Re: Rearrange filename

Postby Temerald » Wed Apr 23, 2014 3:03 am

OK, I was able to add the album (folder) using this information but BRU fails to rename file names containing commas or a non-breakable space within the string.

NOTE: I did search for posts with the word comma; of the results, none of which explain why BRU fails to work on strings containing commas-- and I did a search for "non breakable space"; yielding, "the word breakable is not contained in any post".

Here's the layout:
DISCID-Track## - Category;ArtistLast, ArtistFirst - title of song {errnumber}.ext
What I want:
Category;ArtistLast, ArtistFirst - title of song - DISCID-Track## {errnumber}.ext

In an effort to keep it simple, I used:
#1RegEx, Match:
Code: Select all
(.*) - (.*) - (.*) {(.*)

#1RegEx, Replace:
Code: Select all
\2 - \3 - \1 {\4


All other fields are disabled except #12Selections: Filter is set to * and only Files & Subfolders are checked.

Yet, if a file name contains a comma or a non-breakable space, BRU will ignore the file name completely.

I just want to rename my files without so much stress..

Any help would be wonderful
Thanks in advance.
Temerald
 
Posts: 3
Joined: Tue Apr 22, 2014 10:19 pm

Matching problem

Postby truth » Thu Apr 24, 2014 8:47 pm

Without knowing more details, it sounds like you're dealing with non-matchable unicode chars?
To confirm, disable ALL settings besides 1Regex & use:
.*
---\1---

If that wont match your filename-chars, no other expression in regex will help.
Post back if that's not the case, I will prob be offline for a few days though.
Hopefully, that is not your issue, I do suspect it though.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Rearrange filename

Postby Temerald » Sat Apr 26, 2014 10:50 pm

truth wrote:o confirm, disable ALL settings besides 1Regex & use:
.*
---\1---


OK, I assume you want me enter:
Match
Code: Select all
.*

Replace
Code: Select all
---\1---


Based on that, files that contain a non-breakable space (Character 0160) are not being renamed, the rest are changing to ---\1---.ext

If I am to understand you correctly, because of lack of unicode support, Bulk Rename Utility is useless to me?

Thanks for your help.

I will await your answer, and thanks again in advance.
Temerald
 
Posts: 3
Joined: Tue Apr 22, 2014 10:19 pm

BRU's regex doesnt like Unicode

Postby truth » Sun Apr 27, 2014 11:43 pm

Sorry for the confusion, .* should have been grouped as (.*)
The ----'s make regex-non-matchable-Unicodes stand out from the rest,
while also showing any improperly-matched-UnicodeNames -> ----.ext

BRU's regex doesnt like Unicode, but its other settings do work fine.
Some users have sworn regex-success by changing their system code-page, etc.
But at best, it seems that'd only work for 1 page at-a-time.

'Useless' might be a bit harsh, unless you frequently need to regex Unicodes.
If thats the case, & you need to keep Unicodes, I'd prob use another app.

There are workarounds, but whether worthwhile or not, depends on what you usually do.
You can use CharTrans to convert Unicodes -> chars that 1Regex will match.
It works well for this example.. Basically, you'd use Options/CharTrans to create:
NonBreakSpace= ,
CommaLookAlike=2C,

Just paste the right Unicode-chars before =
The final comma isnt necessary, the 2C represents a literal comma.
Dont know your situation, but you might prefer making a comprehensive CharTrans-file
to translate more Unicodes, & save them into a file (no BRU option will save them).

Since CharTrans processes before 1Regex, it can eliminate the regex-match problem.
Restoring Unicodes (after 1Regex completes) requires more settings and/or separate runs.
Its certainly possible, but I'd weigh workarounds against using apps with a Unicode-compliant-regex.

Many have requested (begged-for) a Unicode-compliant regex, prob its single most requested feature.
I'm lucky, the most I do with Unicodes is translate to ANSI (got some antiquated systems still around).
Sorry I dont have better news for you, hopefully the workaround is enough.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Rearrange filename

Postby Temerald » Mon Apr 28, 2014 6:18 pm

Thank you so much for taking the time to give such a detailed answer. Considering all of the abuse I've seen on other forums, it's a welcomed sight!

Bit harsh? Yea, I guess so but I'm under a deal of stress to re-rip 4,000 (real) CDs over the next few months and I use a non-breakable space to mark the surname of singers so their name can fluidly be flipped. I guess I will stick with TCC LE command line and batch files.

Thanks again for your mature and detailed answers!
Temerald
 
Posts: 3
Joined: Tue Apr 22, 2014 10:19 pm


Return to Regular Expressions