Frustratingly complex regex problem

A swapping-ground for Regular Expression syntax

Frustratingly complex regex problem

Postby Christiebunny » Mon Sep 10, 2012 10:00 pm

I've got a stack of folders and files I'm trying to clean up, easily a thousand or more, and I'm trying to use regex to save me a couple hundred hours and streamline things. I've found a few bits that match fragments here and there, but can't for the life of me figure out anything that works cleanly for more than a few files here and there. This is a sample of some of the folder and filenames:

5 Centimeters Per Second (2007) [1080p,BluRay,x264] - THORA
Astarotte no Omocha! (BD 720p) [Kirakira]
Kampfer - 01-12 (Inc Some Extras) [BD 1080p FLAC]
Shin Koihime Musou[01-12][BDRIP][MP4]+sp
05 16 04[AOST][Konomini Op&Ed]( Single)(320cbr).mp3
Revolutionary Girl Utena The Movie [Anime Fin].MKV
Lucky Star (BD 720p AAC DA)
Animaniacs
Star Trek
[Elysium]Lucky Star EP22(BD 720p AAC DA)[3C5CD3CA].mkv
Fractale [BD][h264-720p][FLAC].[UTW]
Fractale - 03 [BD][h264-720p][FLAC][E2D14722].mkv
[KTXP&DYMY][Shin Koihime Musou][06][BDRIP][X264 AAC][1080p](D6A64E81).mp4



(\[([^]]+)\]) seems to match a bracketed string (sometimes), and I know (.+?) matches everything except the extension. But is there a way, ideally with one regex string and not, say, running 20 different ones one after another, to convert those to:

5 Centimeters Per Second
Astarotte no Omocha!
Kampfer
Shin Koihime Musou
Konomini Op&Ed( Single).mp3
Revolutionary Girl Utena The Movie.mkv
Lucky Star
Animaniacs
Star Trek
Lucky Star EP22.mkv
Fractale
Fractale - 03.mkv
Shin Koihime Musou 06.mp4

It seems to me the answer would be 'no', I may not know regex hardly at all, but it looks to me like a regex that would fix some of them, would ruin others. (Like the fact "Fractale" has its name in brackets and none of the others do, and some have Unicode characters with the name, too, which won't let me post examples of them here!) And, I think running multiple regex's to catch everything, would probably cause later regex's I ran to screw up the results from earlier ones?

Anyone have any ideas? I'd rather not go through each one, one by one, by hand, even going thru and running a regex string separately on each folder would take ages… is there any possible way to clean them all up in one fell swoop?
Christiebunny
 
Posts: 2
Joined: Sat Sep 01, 2012 9:32 am

Re: Frustratingly complex regex problem

Postby Stefan » Tue Sep 11, 2012 6:55 am

If you want to do something automatically all your file names must follow an common scheme.
And especially your last example has nothing to capture automatically.

To remove all brackets and the text inside you can try a few runs with

Ctrl+A
Remove(5)
Crop [Special] [*]
Rename

F5
Ctrl+A
Remove(5)
Crop [Special] (*)
Rename

F5...
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Frustratingly complex regex problem

Postby Christiebunny » Tue Sep 11, 2012 8:49 am

Stefan wrote:If you want to do something automatically all your file names must follow an common scheme.
And especially your last example has nothing to capture automatically.

To remove all brackets and the text inside you can try a few runs with

Ctrl+A
Remove(5)
Crop [Special] [*]
Rename

F5
Ctrl+A
Remove(5)
Crop [Special] (*)
Rename

F5...



That's what I was afraid of - I'll see if that works at all, though, and if not I'll see if it's possible to break them up into folders with similar name layouts :/


UPDATE: That helped a LOT -- probably saved me a week's worth of work, even though I still had to go through them partly by hand to unselect ones that shouldn't be cropped... a couple hours work saved me several days! I've got a long way to go, but between that, and the fact that I can load rename info from files, what would have taken me a month or two is only going to take a week or so. (I never knew about renaming from file OR crop special until just now!)

Thank you so much for the help!
Christiebunny
 
Posts: 2
Joined: Sat Sep 01, 2012 9:32 am

Re: Frustratingly complex regex problem

Postby Stefan » Tue Sep 25, 2012 8:44 pm

Thanks for the feedback! Fine it works for you.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions