1

(15 replies, posted in How to ...)

Well, it's more something like "Good job Stefan" big_smile

2

(15 replies, posted in How to ...)

Hi Stefan.

I hardly ever got as much support in such detail than in this thread by you!

Well ... thanks a lot. I read thoroughly through all 3 posted articles and could simulate perfectly what you wanted me to test. The RegEx works fine for me now, and I got some deep insight into this subject.

Thanks a lot again and merry x-mas!

Bye,

3

(15 replies, posted in How to ...)

Stefan wrote:

If you expression finds the LAST occurrences instead the first ... you have to learn what GREEDY means big_smile
That's how the most RegEx engines works ... find-as-most-as-possible
So have you tried to  limit the match by using an question-mark ? ?
I don't know why your test find the the LAST... maybe you have other filenames then you provide us as examples?
But try to use something like .+? instead of .+

Ok, here one of the real files ...

%f(s/(.+)(\s)/\1 1###2 \2/g)
11;14 (Channel1 - 30112007 1330 169 MP2192g MP2192e AC320384g)_+0+0+160.mpg.abc
11;14 (Channel1 - 30112007 1330 169 MP2192g MP2192e 1###2 AC320384g)_+0+0+160.mpg.abc

Things change with .+?. See below ...

%f(s/(.+?)(\s)/\1 1###2 \2/g)
11;14 (Channel1 - 30112007 1330 169 MP2192g MP2192e AC320384g)_+0+0+160.mpg.abc
11;14 1###2 (Channel1 ...
Stefan wrote:

...
If you want to find more then ONE you search for ANY char/sign and use an quantifier like * or +
So .+ find ANY...   but not ONE item only but as-many-as-possible .... till the RegEx engine find an other expression you search for.
As i sad.. the most RegEx engines are greedy and find more then you want.
So use the ?-modifier to search "lazy"

I don't get this "greedy" stuff. In fact, the .+ only works as expected if I use .+?. \s means "until next space", which is a clear definition. Hence ... why does (.+)(\s) not simply stop at the first space found ?! In other words ... would you mind to explain "greedy" by simple words. Thanks,

Stefan wrote:

g means global and search not only for the first occurrences in an string but for all. See Siren help too.

Search within Siren help didn't reveal any "global". Sorry!

Stefan wrote:

Good work so far Georges. Do you want me to present the solution or do you want "learning by doing"?   You choose.

Let's continue ...

%f(s/(.+?)(_.+)(\..+?)/\1 1###2 \2 2###3 \3 3###4 \4/g)
11;14 (Channel1 - 30112007 1330 169 MP2192g MP2192e AC320384g)_+0+0+160.mpg.abc
11;14 (Channel1 - 30112007 1330 169 MP2192g MP2192e AC320384g) 1###2 _+0+0+160.mpg 2###3 .abc 3###4

For me, this should work. But why does \..+? not stop at . of .mpg? Something like ...
- take everything before _ (excluding)
- take _ and everything behind until next . (excluding)
- take . and everything behind.

Where's the mistake?

Thanks,

4

(15 replies, posted in How to ...)

@Stefan

RegEx ... good stuff, but somewhat difficult without your explanantions.

Can you confirm that:
(.+)(\s) considers everything before the LAST space and excludes the space
(.+\s) considers everything before the LAST space and includes the space

I interpreted your explanation (Find an space \s) as "find the first space". In fact, it seems to be more something like "find the last space". Please correct if wrong.


Why is the "/g" at the end of RegEx (s/search/replace/g)?


Taking up your idea of the second post (all until underscore, then dot and the rest) doesn't work since the search for the atom ("_" and ".") starts from the right ?!?!

The result would be:
%f(s/(.+)(\_.+)(\..+)/\1\3/g)

"expr1 (expr2)_expr3.ext1"      -> "expr1 (expr2).ext1"
"expr1 (expr2)_expr3.ext1.ext2" -> "expr1 (expr2).ext2"

.ext1 is missing in line 2.
.ext1 is (for some reason?) part of /2 (_expr3.ext1)

How come ...?

Thanks,

5

(15 replies, posted in How to ...)

Sorry guys, I messed up my initial posting. The task looks like this:

"expr1 (expr2)_expr3.ext1"      should become "expr1 (expr2).ext1"
"expr1 (expr2)_expr3.ext1.ext2" should become "expr1 (expr2).ext1.ext2"

- In other words ... expr3 changes (is not a constant string). Everything after the underscore (which is unique in the filename base) needs to be disregarded.

- This applies also with a second extension appended (.ext2).

Sorry again ...

Thanks,

6

(15 replies, posted in How to ...)

Hi.

I'd like to get rid of "_expr3".

The following type of files are affected:

"expr1 (expr3).ext" should become "expr1 ().ext"
"expr1 (expr2)_expr3.ext1.ext2" should become "expr1 (expr2).ext1.ext2"

The problem is the 2 different kind of files with 1 and 2 extensions.

How can I tell Siren to delete "_expr3"?

Thanks,

Tricky again, but it works fine. Thanks!

Is it possible to add in the next Siren release a %ncs variant which considers the extension?

Regards,

Hi.

I take lots of raw pictures with my camery. Infact, I use the option jpg+raw, hence date and time of both shots are identical. I use the following expression:

%Xdod-%Xdot-c%ncs.%le

Source files ...

IMG_9378.CR2
IMG_9378.JPG

... result in ...

20070726-093747-c.cr2
20070726-093747-c_001.jpg

Any idea how I can easily can get rid of the _001 for the .jpg?

Many thanks!

9

(8 replies, posted in How to ...)

Ok. Thanks a lot (again)!

10

(8 replies, posted in How to ...)

Hi guys.

THANKS A LOT!

The shortest version was the one from Rémi.

%f(s/(.*\().*(\).*)/$1$2/)

It worked perfectly.

However the bottomline for me was also to understand what happend here! Thanks to the explanations of Stefan, I managed to get it more or less.

%f(s/(.*\().*(\).*)/$1$2/)

(.*\() - variable $1 - everything until last opening bracket (including this).
.* - delete everything after until ...
(\).*) - variable $2 - ... next bracket - include this bracket and everything right of it.

Is this correct?
This is tricky stuff!

BTW ... The Siren Help (F1) doesn't explain regular expression (all which comes after "s/"). Where do you get these "commands" from (à la (.*), (.+), ...)?

What is that with those [1] thinggies? I didn't understood. You want them or not?

Yes, I do need them.

Many thanks again. Great job, and powerful software!

Bye,

11

(8 replies, posted in How to ...)

In fact, I forgot one file type ...

"expr1 (expr3).ext" should become "expr1 ().ext"
"expr1 (expr2) (expr3).ext" should become "expr1 (expr2) ().ext"
"expr1 (expr3)[1].ext" should become "expr1 ()[1].ext"
"expr1 (expr2) (expr3)[1].ext" should become "expr1 (expr2) ()[1].ext"

Sorry, but I can't get this [1] to remain sad

Any ideas?

Thanks,

12

(8 replies, posted in How to ...)

Is it possible that this is the solution?

%b[-2,"("] ().%e

Thanks,

Bye,

13

(8 replies, posted in How to ...)

Hi.

I'd like to get rid of expr3 (stuff between brackets only).

The following type of files are affected:

"expr1 (expr3).ext" should become "expr1 ().ext"
"expr1 (expr2) (expr3).ext" should become "expr1 (expr2) ().ext"

The problem is the 2 different kind of files (expr2).

How can I tell Siren to delete expr3?

Thanks,

14

(3 replies, posted in How to ...)

Stefan wrote:

Hi Georges, welcome.

...

HTH? big_smile

It did. Thanks a lot!
Would have been surprised if Rémi would not have included such a feature!

Bye,

15

(3 replies, posted in How to ...)

Hi.

While renaming pictures using EXIF information, dupes appear from time to time. How can I automatically avoid errors?

E.g. is it possible to add "_dup" to the basename instead of creating an error?

Thanks,