1 (edited by Stefan 2007-04-22 01:20:27)

Topic: Replace the '.' (dots) with ' ' (spaces)

Replace the '.' (dots) with ' ' (spaces)



   From:
   My.preferred.movie.avi

   To:
   My preferred movie.avi

   Use the expression:
   %b("."," ").%e



   How does it work ?
   Here, we use the replacement modifier with two parameters, the string to replace and the replacement string.
   We want to substitute all the '.' with ' ',
   so the first will be "." and the second " "
    
   We apply this modifier on "%b" which is the base name (file name without extension).
   Applying it on "%f" (full name), we would have replaced the '.' just before the extension too.

   %e, the file extension is "avi"

   So, following the expression:
   %b                  gives "My.preferred.movie"         [this is the original name without the extension]
   %b("."," ")       gives "My preferred movie"         [we have replaced the dots with blanks. Because of the 'b' we work on the 'base name' only]
   %b("."," ").      gives "My preferred movie."        [we add an dot to the base name to set the extension apart]
   %b("."," ").%e gives "My preferred movie.avi"    [we add now the original extension too]



   --
   For more details just download Siren at http://www.scarabee-software.net/en/siren.html and consult the help.
   No installation needed, unzip and run. Siren stores it settings into an ini file.   <Here> you can see some screen shots of Siren.
   Enjoy Siren, the powerfully portable freeware renamer.

2

Re: Replace the '.' (dots) with ' ' (spaces)

Damn it, Stefan!! No way to determine how indebted I am to you!! ;-)

Thanks so much for sharing your valuable knowledge. Keep it up!

3

Re: Replace the '.' (dots) with ' ' (spaces)

How to go about renaming this:

foobar.the.audio.player.9.4.3

to

foobar the audio player 9.4.3?

4 (edited by Stefan 2007-05-16 22:33:12)

Re: Replace the '.' (dots) with ' ' (spaces)

RR wrote:

How to go about renaming this:
foobar.the.audio.player.9.4.3
to
foobar the audio player 9.4.3?

Looks tricky but it's easy with Siren.

First attempt

ORIGINAL:      foobar.the.audio.player.9.4.3
EXPRESSION: %NN("."," ")%N.%N2.%e
RESULT:         foobar the audio player 9.4.3

EXPLANATION:
%NN      : the first non numeric string contained in the base file name                                             [foobar.the.audio.player]
("."," ")   : search in the result of %NN for dots and replace them with blank                                     [foobar the audio player]
%N        : a number contained in the base file name, a digit can indicate its position (1 by default)     [foobar the audio player 9]
.            : an dot                                                                                                                         [foobar the audio player 9.]
%N2       : the second number in the base file name                                                                       [foobar the audio player 9.4]
.            : an dot                                                                                                                         [foobar the audio player 9.4.]
%e        : the extension (Siren use here the  .3   as the extension because of the "last dot rule")       [foobar the audio player 9.4.3]



HTH?

Re: Replace the '.' (dots) with ' ' (spaces)

RR wrote:

Damn it, Stefan!! No way to determine how indebted I am to you!! ;-)

Thanks so much for sharing your valuable knowledge. Keep it up!

Thank you RR, but this is this time just the text from the help from Siren ;-)
I put it here only so people can see what to do with Siren.
So this thanks goes to our lovely rplr! big_smile

Re: Replace the '.' (dots) with ' ' (spaces)

RR wrote:

How to go about renaming this:
foobar.the.audio.player.9.4.3
to
foobar the audio player 9.4.3?

Not as good as above ... but can help maybe sometimes:



EXPRESSION:      %b[1,"."] %b[2,"."] %b[3,"."] %b[4,"."] %b[5,"."] %b[6,"."].%e


EXPLANATION:
%b[1,"."]           First part of the name till the first dot                  [foobar]
an blank                                                                                   [foobar ]
%b[2,"."]           Second part of the name till the next dot             [foobar the]
etc.




From the help:
Every variable can be postfixed by a "[]" modifier.
It will be split into an array of substrings following the
specified separator characters.
The usage is: "[ i , "sep" ]"

   i   : number of the substring to extract.
         If negative, the extraction is done from the end.
         If "0" (zero), it's equivalent to the complete string
         without the beginning and ending spaces.
   sep : list of separator characters, optional.
         If it is not specified, the list defined in
         "Options/Modifications" is used.



-----------------------------------------------
It's looking tricky but it's easy with Siren.

Re: Replace the '.' (dots) with ' ' (spaces)

Hi,

Maybe two other solutions to add to Stefan's ones (thanks smile).

%f("."," ",1,4)
You already know %f("."," ") to change every "." with " " (space).
The two "new" parameters: 1 and 4 "tell" to do the replacement from the first "." four times.

The other one can look a bit strange because it uses a regular expression and another method:
%f(s/([a-z])\./$1 /gi)
It will replace all "." following an alphabetic character (from a to z) with a " " (space)

There are surely other ways to achieve it.
All depends on your exact needs.

8

Re: Replace the '.' (dots) with ' ' (spaces)

Awesome people! How do I get to learn to be as good?!!
Thank you so much.

Re: Replace the '.' (dots) with ' ' (spaces)

RR wrote:

Awesome people! How do I get to learn to be as good?!!
Thank you so much.

You are able to learn all you want on earth, it may take some time as i see with myself ;-)
Just play around, ask questions if you need, post solutions in the How to section...
Siren itself comes with an help, faq and some examples.... look in the '?'-menu.
Did you need some RegEx help ... i will post some links.

And in front off all: "Thank you very much for your feedback RR!"

10

Re: Replace the '.' (dots) with ' ' (spaces)

Yes, Stefan, RegEx help will be very nice. Especially some readymade lines like 'insert xx character at xx place', 'first/second/third occurrence only', etc. Thanks for being so open.

11

Re: Replace the '.' (dots) with ' ' (spaces)

I got one more here. Please mull it over:

         foobar - the audio player [2007]

to be renamed as

        2007 - foobar - The Audio Player [2007]

I can reach this far: 2007 - Foobar - The Audio Player [2007]

Re: Replace the '.' (dots) with ' ' (spaces)

You can get it with an expression like: %f[2,"[]"] - %f[1] - %Uf[2]

%f[2,"[]"]: the second parameter "[]" tells the array extraction to use '[' and ']' as separators in place of the default ones. So the second element will be "2007"

%f[1]: extracts the first element based on the default separator ('-'). So it will return "foobar"

%Uf[2]: if %f[2] returns "the audio player [2007]" the character modifier 'U' will change the case of this string by setting the first letter of each word uppercase and the rest lowercase.

You can define the default array element separators in "Options/Modifications".

Hoping this will help.

Re: Replace the '.' (dots) with ' ' (spaces)

As mostly you can solve tricky problems with Siren in different ways. Here's an another one:

EXAMPLE:          foobar - the audio player [2007]
EXPRESSION:    %N - %Ub
RESULT:           2007 - Foobar - The Audio Player [2007]

EXPLANATION:
1)  %N   : a number contained in the base file name  a digit can indicate its position (1 by default)  [2007]
2)   Blank Underscore Blank                                                                                                      [2007 - ]
3)   %Ub  : The base name  AND   U : first character of each word upper case,                             [2007 - Foobar - The Audio Player [2007]]


BUT...
since you want the word 'foobar'  in lower case ....
we have to split the base name into two parts......
one part will be still lower case... and the second we modify to upper case.


From Siren help (press F1 in Siren):
Every variable can be postfixed by a "[]" modifier.
It will be split into an array of substrings following the  specified separator characters.
The usage is: "[ i, "sep" ]"

EXAMPLE:          foobar - the audio player [2007]
EXPRESSION:    %N - %b[1] - %Ub[2]
RESULT:           2007 - foobar - The Audio Player [2007]

EXPLANATION:
1)  %N   : a number contained in the base file name  a digit can indicate its position (1 by default)  [2007]
2)   Blank Underscore Blank                                                                                                      [2007 - ]
3)   %b[1]  :extracts the first element based on the default separator ('-')    "foobar"                     [2007 - foobar]
4)   Blank Underscore Blank                                                                                                      [2007 - foobar - ]
4)  %Ub[2]   :extracts the second part and make it upper case the first char                                 [2007 - foobar - The Audio Player[2007]]

This is like rplr told in the post above but i use the %N parameter.


------------------------------------------------------------------------------------------------------------

                                             Siren is a freeware file renaming program
                                               - portable, highly flexible, powerfully -
                                          If it's looking tricky it's easy to rename with Siren.
                                          http://www.scarabee-software.net/en/siren.html

14

Re: Replace the '.' (dots) with ' ' (spaces)

Thanks again!

Lemme sleep on it.