Page 1 of 1

Complex name edit - RegExp or Script?

Posted: 11 Sep 2008 16:53
by ivan
I am in need of a method that would automate manipulating with file names and getting them to be how I want them to be.
The file names in question (excluding extensions) have segments of either just letters or combinations of letters and numbers and those segments are separated via dots.
So I guess what I need is a method (that I hope either RegExp or Scripting provide) for XY analyze each segment and act according to pre-requisites.

Here are the pre-requisites:
1. If a segment has only letters then capitalise the first letter, unless...
a) a segment matches one of preset segments, in which case capitalise all letters
2. If a segment matches a wildcard pattern such as a**b**, where * is always a number (in this case), then "a" and "b" will be capitalised.

Logically, I'd like to assign a KS to this operation so I can select a file (or multiple), hit a KS and voilĂ .
I understand that this is a custom kind of job and is a challenge, but I'm looking to dig deep into XYplorer's scripting and RegExp rename capabilities so any help would be very much appreciated.

Thanks a lot in advance! :)

Re: Complex name edit - RegExp or Script?

Posted: 11 Sep 2008 17:01
by j_c_hallgren
Could you provide a few samples of before/after with the various conditions? It would help clarify what you want, ok?

Re: Complex name edit - RegExp or Script?

Posted: 11 Sep 2008 17:09
by TheQwerty
Well you know where XY's help file and wiki are, combine that knowledge with some of the examples from the forums and you can figure out how to write a script.

As for understanding Regular Expressions, http://www.regular-expressions.info/ is a great resource.

Re: Complex name edit - RegExp or Script?

Posted: 11 Sep 2008 17:17
by ivan
j_c_hallgren wrote:Could you provide a few samples of before/after with the various conditions? It would help clarify what you want, ok?
Silly me for not thinking of that when creating a thread :oops: Here they are:

Initial name:

Code: Select all

name.p01c01.word.document.docx
Final name:

Code: Select all

Name.P01C01.WORD.Document.docx
I think above example showcases all 3 pre-requisites quite well, I hope... :lol:

P.S.
Of course it can also be
Initial name:

Code: Select all

name.header.p01c01.word.document.docx
in which case logically
Final name:

Code: Select all

Name.Header.P01C01.WORD.Document.docx

Re: Complex name edit - RegExp or Script?

Posted: 01 Oct 2008 15:43
by ivan
OK, I decided to go with scripting all the way, but I have found some shortcomings that make the job not possible.

1. rename doesn't support capitalisation.
2. Capitalisation doesn't support configurable symbols of word separation.
3. Capitalisation is only applicable to first word in a file name, while it's very plausible for it to be used several times.
4. "*" (asterisk), which is normally a wild character isn't supported in rename as a possible wild character.

Also, I have a couple of questions:
a) In

Code: Select all

rename [mode (b|r|s|k|e)], pattern, [preview (p)], [itemlist]
can [itemlist] be set to a variable name of a file?
b) In the same rename command, how is it possible to specify multiple patterns per single rename operation?