Complex name edit - RegExp or Script?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Complex name edit - RegExp or Script?

Post 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! :)
Windows Vista Business SP1 32-bit, Logitech MX400 mouse, SetPoint 4.60.122
Image

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: Complex name edit - RegExp or Script?

Post 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?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Complex name edit - RegExp or Script?

Post 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.

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Re: Complex name edit - RegExp or Script?

Post 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
Windows Vista Business SP1 32-bit, Logitech MX400 mouse, SetPoint 4.60.122
Image

ivan
Posts: 577
Joined: 02 Apr 2008 12:52
Contact:

Re: Complex name edit - RegExp or Script?

Post 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?
Windows Vista Business SP1 32-bit, Logitech MX400 mouse, SetPoint 4.60.122
Image

Post Reply