#1 2007-02-06 19:44

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Renamer V4.5 and wildcards

In the V4.5 the 'What's new' log states
Wildcards can now be used within Remove and Replace rules!

Have you got any examples of how this can be used?

Same with the note
Added new "Move filename portion" script for PascalScript rule

There's no documentation, so I cant even guess how to use this??

On the plus side, widestrings are much easier now, and the themeing is almost perfect with a manifest
The almost being that the checkboxes at the far left are cut off by one or two pixels - but thats a really minor point big_smile

Offline

#2 2007-02-06 21:23

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Renamer V4.5 and wildcards

Long time no hear! smile

About Wildcards... To be honest, didn't expect that question from you! Would've thought that you would defiantly know what and how to use these wildcards, since you are a programmer as well. Anyway, here comes the explanation:

*     An asterisk matches any number of characters.
?     The question mark matches any single character.
[ ]   Brackets enclose a set of characters, any one of which may match a single character at that position.
-     A hyphen used within [ ] denotes a range of characters.

Examples for Remove rule:
abc*   - remove part of the filename which starts from "abc" to the end of the filename.
ab?d   - remove parts like: "abcd", "ab1d", "ab d", "ab_d", etc.
foo[ab]ar   - remove occurrences of "fooaar" and "foobar".
foo[a-z]ar   - remove occurrences of "fooaar", "foobar", "foocar", "foodar", etc.

About "Move filename portion" script... I really don't recognise you man! I thought you are a Delphi programmer?! Anyway, script moves a portion of a filename to another position within a filename. 3 Constants at the top of the script specify where that portion starts, it's length, and it's new position (MOVE_START, MOVE_LENGTH, MOVE_TO). Any clearer?

About manifest... Good news, I've fixed the rest of incompatibilities with the manifest! But I didn't yet add manifest to the distributed versions. Try adding manifest to latest development version: ReNamerBeta.zip

Offline

#3 2007-02-07 19:57

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Renamer V4.5 and wildcards

<sigh> I'm getting lazy in my old age tongue

I'm actually reading the docs lately instead of playing with things and finding out how they work

"Move filename portion" script
I'm embarrassed, I'm so used to just writing the code, that I forgot the 'helper' button was on the pascalscript dialog!!
roll

re the wildcards - that was more of a query about how they were implemented (theres soooo many ways of doing it)
being able to use the wildcard part in the output filename would be a nice feature
eg a replace rule like 'dsc*-date-*'->'My Picture %2 (%1)' to transform
'dsc1-date-2007-01-01.jpg' to My Picture 2007-01-01 (1)
or if you want ambitious then
'dsc*-date-*'->'My Picture %2 (%1#3)'
'dsc1-date-2007-01-01.jpg' to My Picture 2007-01-01 (001)

big_smile

Offline

#4 2007-02-07 20:12

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Renamer V4.5 and wildcards

den4b wrote:

About manifest... Good news, I've fixed the rest of incompatibilities with the manifest! But I didn't yet add manifest to the distributed versions. Try adding manifest to latest development version: ReNamerBeta.zip

This works fine here - no visual problems
The only criticism I can give is that when you have 10 or more rules only the first number is shown instead of the column being resized to show the widest number
It's an unimportant thing (last thing I'd be working on!), but it's so easy to fix and the end-users DO like their 'pretties'

That's about the only improvement I can think of visually - the rest is pretty much spot on

Offline

#5 2007-02-08 12:30

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Renamer V4.5 and wildcards

dloneranger wrote:

re the wildcards - that was more of a query about how they were implemented (theres soooo many ways of doing it)
being able to use the wildcard part in the output filename would be a nice feature
eg a replace rule like 'dsc*-date-*'->'My Picture %2 (%1)' to transform
'dsc1-date-2007-01-01.jpg' to My Picture 2007-01-01 (1)
or if you want ambitious then
'dsc*-date-*'->'My Picture %2 (%1#3)'
'dsc1-date-2007-01-01.jpg' to My Picture 2007-01-01 (001)

All that can already be done with RegEx rule! big_smile I know they are a bit more complex and perhaps are harder understand, but they provide far more functionality than the wildcards do. In the matter of fact, I've actually done wildcards processing by converting them into regular expressions and passing to the replace procedure of regular expressions engine. Do you know any freeware code that has search-replace function which supports wildcards?? I've been searching for one, but without any results...

dloneranger wrote:

The only criticism I can give is that when you have 10 or more rules only the first number is shown instead of the column being resized to show the widest number. It's an unimportant thing (last thing I'd be working on!), but it's so easy to fix and the end-users DO like their 'pretties'

Somehow I knew you would notice that! wink I've noticed it as well, but didn't think that people are actually using more than 9 rules at a time, well, at least I never used even more that 6 rules at a time (as many as can fit in the default height of the table). I was thinking of dropping the numbers, what do you think? Are they really useful, at all?

Offline

#6 2007-02-08 19:11

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Renamer V4.5 and wildcards

Do you know any freeware code that has search-replace function which supports wildcards?? I've been searching for one, but without any results...

Not off hand - the only ones I've done used 2 string arrays, one boolean array and the search+replace string
Then I just split the strings into arrays and replaced the output parts as needed
So, I'd take something like - replace 'pic*-date-*.jpg' with '%2 (%1).jpg'
split the input into an array for the input and set the boolean for wildcard as needed
this would give two arrays like
iswild, instring
0 - 'pic'
1 - '101'
0 - '-date-'
1 - '2007-01-01'
0 - '.jpg'

then I can use any part for the output string (I did merge multiple '?'s into one entry as its pretty obvious that '???'=one three string item)
although looking at it - I can't see the reason I kept the parts that weren't wildcards, I could have ignored them and saved the use of the boolean array as well
also I cheated a bit as I didn't need to support [] and -, just * and ?, but thats. not really too much extra work


I was thinking of dropping the numbers, what do you think? Are they really useful, at all?

To be honest, I can't really see the point of them, they're a bit like line numbers in old source code
Do you really need to know than they go 10,20,30 ??
The only important part is already shown visually - they go from top to bottom
The only time I found line numbers interesting was with something I think was called an Oric Atmos back in the 80's
It actually had floating point line numbers big_smile
Bizarre, but at least you didn't need a renumbering function to be able to add a line between line 10 and 11 and also provided source code protection!! (make the number long enough and the code was off the side of the screen)

Offline

#7 2007-02-09 23:52

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Renamer V4.5 and wildcards

Wildcards.... ReNamer is now able to use wildcards matches in the replace operation, using backreferences, e.g. $1, $2, $3, etc. I do all the tricks by converting wildcards into regular expressions, which then passed over to a regular expressions engine (TRegExpr). The code below demonstrates the transformation for 'Find Expression', while 'Replace Expression' doesn't have to be altered at all, because '$n' are processed by TRegExpr naturally as backreferences. Try ReNamerBeta.zip again.

Numbers.... lol .. no words, it had to be cooool being a programmer in 80's big_smile

// Convert string with wildcards into regular expression, supports:
//   "?"   - any single character
//   "*"   - any number of any characters
// "[abc]" - single character that matches any one within brackets
// "[a-z]" - single character that matches character in specified range
function ConvertWildcardsToRegEx(const Input: WideString): WideString;
var I: Integer;
begin
  Result := '';
  for I:=1 to Length(Input) do
    case Input[i] of
      '*': Result := Result + '(.*)';  // replace * with .*
      '?': Result := Result + '(.)';   // replace ? with .
      '[': Result := Result + '[';   // leave [ intact
      ']': Result := Result + ']';  // leave ] intact
      '(',')','&','^','.','{','}','|','\':
        Result := Result + '\' + Input[i]; // escape all meta chars
      else
        Result := Result + Input[i];  // else append to result
    end;
  // surround [..] with brackets, i.e ([..])
  Result := ReplaceRegEx(Result, '(\[.*?\])', '($1)');
end;

Offline

#8 2007-02-10 20:50

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Renamer V4.5 and wildcards

Am I doing something wrong, but it doesn't seem to work - I've got the latest beta that mentions it in the halp

eg
A simple replace rule
replace -> 'copy * renamer' -> 'old $1'
results in the new name of 'Copy of Renamer.exe' not 'of.exe' as I would have expected

I've tried a few combinations but I just can't get it to work

-----

Numbers.... lol .. no words, it had to be cooool being a programmer in 80's big_smile

Darn - your making me feel OLD!!!! tongue
Ah, the joys of converting Z80 opcodes into hex and poking them into memory to be executed
But, that's going back to the time when my PC had 1K of memory and your largest program could only be 600 bytes !!!
Happy times! Sitting in class, ignoring the lessons and writing 'space invaders' programs - I think I finally got it down to 400 bytes

Last edited by dloneranger (2007-02-10 21:49)

Offline

#9 2007-02-11 13:43

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: Renamer V4.5 and wildcards

I think you simply forgot to tick an option called "Interpret ?, *, [] as wildcards and $n as backreferences" (in the Replace rule). wink

By the way, the latest dev version will be processing "*" in a non-greedy mode.

Offline

#10 2007-02-11 16:19

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Renamer V4.5 and wildcards

Darn - I've done it again - missed the bl***y obvious!!! roll

Works perfectly!
Damned nice piece of work, it's much more 'user friendly'

Offline

Board footer

Powered by FluxBB