#1 2013-02-13 00:55

Mountie
Member
Registered: 2013-02-13
Posts: 4

Replace only the first two diggits

Hello community,

I downloaded ReNamer and guess it is a wonderful program.

My files are named like this:

99-1010.jpg
99-1011.jpg

Now - I want to replace only the first two characters (99) into wood-99-

The result should like this:   wood-99-1010.jpg

The first time it is wonderful - but after starting the program a second time
and scanning the whole files again - the result will be like this:

wood-wood-99-1010.jpg

How can i define that the program will scan only the first two characters and replace them?

I am sorry about my bad english.  :-(

Hope you'll understand my problem. :-)

Best greetings

Mountie


Wer fragt bleibt einen Moment unwissend, wer nicht fragt sein ganzes Leben.

Offline

#2 2013-02-13 01:03

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

Re: Replace only the first two diggits

Hello Mountie, and welcome!

You can use the following RegEx rule to do that:
* Replace expression "\A(\d+)" with "wood-$1" (skip extension)

This will insert "wood-" only in front of filenames that start with digits.

More information about Regular Expressions available here:
http://www.den4b.com/wiki/ReNamer:Regular_Expressions

Offline

#3 2013-02-13 07:31

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Replace only the first two diggits

Hello, just one little improvement.

Mountie wrote:

Now - I want to replace only the first two characters (99) into wood-99-

den4b wrote:

You can use the following RegEx rule to do that:
* Replace expression "\A(\d+)" with "wood-$1" (skip extension)

The RegEx pattern "\d+" means "one-or-more of a single digit".
This would also find more then two digits, also maybe three or four too.

FROM:
99-1010.jpg
99-1011.jpg
101-1010.jpg
101-1011.jpg
991010.jpg
991011.jpg
TO:
wood-99-1010.jpg
wood-99-1011.jpg
wood-101-1010.jpg
wood-101-1011.jpg
wood-991010.jpg
wood-991011.jpg



To make it more perfect i would search for exactly two digits by using "\d\d"
and additionally, to be even more precise,  only if the digits are followed by an hyphen: "\d\d-"

Read: match an leading digit, followed by an second digit and an hyphen.

Use RegEx rule
* Replace expression "\A(\d\d-)" with "wood-$1" (skip extension)

FROM:
99-1010.jpg
99-1011.jpg
101-1010.jpg
101-1011.jpg
991010.jpg
991011.jpg
TO:
wood-99-1010.jpg
wood-99-1011.jpg
101-1010.jpg
101-1011.jpg
991010.jpg
991011.jpg

.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2013-02-13 10:51

Mountie
Member
Registered: 2013-02-13
Posts: 4

Re: Replace only the first two diggits

Hello den4b, hello Stefan,

thanks a lot for the quickly response.

I guess that I explained my problem not exactly.

This are the files: (more different examples)

99-1010.jpg
99-1011.jpg
50-1010.jpg
50-2010.jpg

I want to make such a result:

wood-99-1010.jpg
wood-99-1011.jpg
metal-50-1010.jpg
metal-50-2010.jpg

With \A\d\d-   wood-$1 EVERY filename will be replaced with wood.

I want to create a rule (or more rules) like this:

Rule1
Read the first two charakters.
If charakters= 99- then replace with wood-99-

Rule2
Read the first two charakters.
If charakters= 50- then replace with metal-50-

Pascal script? hmm

O.K. - I will read again at the wiki side.

@den4b
The program is very powerful - congratulations to this perfekt work.

Hope to find a solution.

see ya

Mountie


Wer fragt bleibt einen Moment unwissend, wer nicht fragt sein ganzes Leben.

Offline

#5 2013-02-13 11:38

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Replace only the first two diggits

Mountie wrote:

With \A\d\d-   wood-$1 EVERY filename will be replaced with wood.

I want to create a rule (or more rules) like this:


Then find and replace literally.

FROM:
99-1010.jpg
99-1011.jpg
50-1010.jpg
50-2010.jpg
TO:
wood-99-1010.jpg
wood-99-1011.jpg
metal-50-1010.jpg
metal-50-2010.jpg

Rule:
search literally for "99-" at the beginning (\A) of an string and replace literally by "wood-99-"
search literally for "50-" at the beginning (\A) of an string and replace literally by "metal-50-"

USE:
1) RegEx: Replace expression "\A99-" with "wood-99-" (skip extension)
2) RegEx: Replace expression "\A50-" with "metal-50-" (skip extension)
3) RegEx: Replace expression "\A33-" with "glas-33-" (skip extension)
4) ...
5) ...


Use "Presets > Save as..." to save this for later use.

Solved?


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#6 2013-02-13 11:48

Mountie
Member
Registered: 2013-02-13
Posts: 4

Re: Replace only the first two diggits

Hi Stefan,

oh man - so easy - but I didn't managed it alone.

Now it runs very good. Thanks a lot for your help and your patience. (!)

Have a nice day

Mountie


Wer fragt bleibt einen Moment unwissend, wer nicht fragt sein ganzes Leben.

Offline

Board footer

Powered by FluxBB