Topic: Renumber starting with a number?

Wonderful program! Have used it with many different formulas.

However, I'm wondering if you could give an example of how to renumber starting with a given number (such as renumbering from 6901 on).

Thanks!

Re: Renumber starting with a number?

Welcome and thanks,

You can do this by using the specialized modifier associated to selection numbers.
For example, if you want to prefix the current file name with the selection number starting at 6901, use an expression like:
%n{5,6901} - %f

5 : is the final size, in this case the first file will start with: 06901.
You can change the value there, eventually omit it.

6901 : is the start value

A third parameter, the increment, has not been specified.

By default all missing values are taken from "Options/Numbers". Therefore if you don't want to use the "{}" modifier, just modify the "Options".

Hope this will help,

Remi

Re: Renumber starting with a number?

Perfect. Thanks so much!

4 (edited by Stefan 2012-05-19 16:43:41)

Re: Renumber starting with a number?

Q:  How can i change the leading numbers, e.g.:

      FROM:
      1 - file 1.txt
      2 - file 36.txt
     
      TO:
      16 - file 1.txt
      17 - file 36.txt

 
 
   
A: First idea is to do this in two steps:
     1.) remove leading numbers
     2.) add new numbers starting at '16'
   
   
   
How-to:

    - Select all files in Siren
        ( take care to have the files in the wanted order,
          AND to select them top-down one-by-one, or all the same time,
          because the %n parameter takes the selection order into account)

    - Type this into the Expression field:
       %f(s/^\d+//);%n{1,16,1}%f

   - execute menu "Action > Recompute" for an preview
   

   
   
Explanation:

    This are two expression, separated by an semicolon
    %f(s/^\d+//)
    ;
    %n{1,16,1}%f
   
       
    The first expression is an regex search and replace
    which search for leading digits and replace them with nothing, meaning: remove them.
   
    The second adds an counter "%n" in the order the files are selected.
        (if you don't see the right sequence 16,17,18,... un-select and select again)
    The parameter  {1,16,1} is an modifier and stands for {padding width, start at, step width}
    Then the rest of the original (new computed from the first expression) file name is added by the %f variable.
   

   


- - -



  But with Siren you can do it more then one way:



Q:  How can i change the leading numbers, e.g.:

      FROM:
      1 - file 1.txt
      2 - file 36.txt
     
      TO:
      16 - file 1.txt
      17 - file 36.txt


A: You could use the "%N" (upper case N !!!) variable:

      %N   : a number contained in the base file name
               A digit can indicate its position (1 by default)


      The parameters of some "number" variables can be defined in "Options" ("Numbers" sub-menu).
          They can be specified too directly in the expression inside a "{}" modifier (braces)
           that postfixes the variable name.

      For the numbers contained in the base file name: %N, %N1, %Nn ...
          the usage is: "{ p, v, n }"
                p : size / pad (length of the number, padded with zeros if needed)
                v : value to add (positive or negative)
                n : position of the number to extract. If negative, the extraction is done from the end.
       
   
How-to:

      - Select all files in Siren

      - Type this into the Expression field:

       %N


      - execute menu "Action > Recompute" for an preview
     
     You will get:
     001
     002

     (the number is padded with two zero as defined in "Options"  IF your Siren settings is still the default)
     
     
     
     OK, that have to be improved, and we have to see how to get the rest of the file name.
     
     
     First, we do the adjustment of this numbers:
     
     -  modify the expression to %N{2}

     You will get:
     01
     02

    (do you remember the modifier "{ p, v, n }"  for the number variable?
      or more clearly: "{ padding width, value for calculation, pos of number to extract from the name }")


     
     
     
    Since we wanted to add '15' to the leading numbers to get '16'

     -  modify the expression to %N{2,15}

     You will get:
     16
     17


    Done!  big_smile

     
     
     
   What please?    neutral
   Ohh, you want the remaining part of the name too?  OK:  tongue





   To get the rest of the file name you can

     -  modify the expression to %N{2,15}%f

     You will get:
     161 - file 1.txt
     172 - file 36.txt

     The "%f" variable will get you the whole file name incl. the extension.
     
     But since we do not need the first sign here (the digits '1' and '2') we can
     add an modifier to the '%f' variable too to get the file name from the second sign to the end:
     (Check the help for   String modifier : "( )"  to see how this works)


     -  modify the expression to %N{2,15}%f(2)

     You will get:

     16 - file 1.txt
     17 - file 36.txt


     Pretty fine!  Done?   big_smile
   
     
     
     
    Yes, mostly. But what if i had file names like:

     1 - file 1.txt
     2 - file 36.txt
     21 - file 4.txt
     32 - file 6.txt



    And with an expression like %N{2,15}%f

    you will get:

     161 - file 1.txt
     172 - file 36.txt
     3621 - file 4.txt
     4732 - file 6.txt

    Here i had to remove one time 1, and the other time 2 signs from the beginning?
    I had to use %f(2) and then %f(3) depending on the amount of leading digits????
    How can i do this????



   Well, here i would use an other modifier for the "%f" variable:

     -  modify the expression to %N{2,15}%f[2]

     You will get:

     16file 1.txt
     17file 36.txt
     36file 4.txt
     47file 6.txt

     (IF your Siren settings is still the default and "-" is still the default "Array elements separators" in the options.
          Check the help for   String modifier : "[ ]"  to learn how this works)
          In short: that %f[2] will split your file name at the   "-" delimiter,  as set in the options,
                        and the '2' will get use the second part of the split-ed name.




     Now just add the missing "space dash space":

     -  modify the expression to %N{2,15} - %f[2]

     to get the wanted:
     
     16 - file 1.txt
     17 - file 36.txt
     36 - file 4.txt
     47 - file 6.txt




      Done!  big_smile



      ? please ?   hmm

      Ok, Ok, i understand: what if you want to do the math on the second number from the file name?  smile


      To modify the second number found in the name, you can change the expression

      to %N{2,15,2}
      or
      to %N2{2,15}

     to get:

      16
      51
      19
      21



      And to get the rest of the file name you can maybe use an regular expression
      since the length of the name is different from file to file:

      Expression:  %b(s/(.+ )\d+/\1/)%N2{1,15}.*
      (From the base name, match all till trailing digits, then drop those digits in the replacement)


     What? You don't speak RegEx? That looks crazy as hell?
     Nema problema!  cool

     Just use the power of Siren to do this for you and use the "%NN" variable.

      See help Variables > Base > %NN
                             %NN, the "opposite" of %N : a non numeric string contained in the base file name
                                                                            A digit can indicate its position (1 by default)




     With that knowledge we can use this crude looking expression

     %N%NN%N2.*

      to get:

      001 - file 001.txt
      002 - file 036.txt
      021 - file 004.txt
      032 - file 006.txt
     
     
            %N     will hold the first number in the name
            %NN   the first non-digit part of the name
            %N2   the second number in the name
            .*       just adds the original extension.
     
     
      and that combined with the above explained number-variable modifiers

      %N{1}%NN%N2{2,15}.*

      you get the wanted:

      1 - file 16.txt
      2 - file 51.txt
      21 - file 19.txt
      32 - file 21.txt

      or even change the first %N{1} to %N{2}

      to get:

      01 - file 16.txt
      02 - file 51.txt
      21 - file 19.txt
      32 - file 21.txt

      ---------------------------
      To show the possibilities, here an more complex example.
      Again, modify the second number from the file name:

      FROM:
      1 - file 1 test1.txt
      2 - file 36 check2.txt
      21 - file 4 look3.txt
      32 - file 6 adjust4.txt

      Expression:
      %N{1}%NN%N2{2,15}%NN2%N3{1}.*

      TO GET:
      1 - file 16 test1.txt
      2 - file 51 check2.txt
      21 - file 19 look3.txt
      32 - file 21 adjust4.txt

      Explanation:
      %N to get the first number "32"
      %NN to get the first non-number part " - file "
      %N2 to get the second number "6" which get calculated by {2,15} to "21"
      %NN2 to get the second non-number " adjust"
      %N3 to get the thirs number "4"

      With other renamers you would have to build an regex like:
      %b(s/(.+ )\d+(.+)/\1/)%N2{2,15}%b(s/(.+)\d+(.+)/\2/).*
      Compared to that the syntax of Siren is more then simple and user friendly.
      ---------------------------
     
     
      Done?  roll
      Yes?  big_smile
      Phuu!  smile
      OK, your welcome!  cool

      Depending on your file name the way to your solution may differ from this examples.
      But in the help you will find all possible variables to solve your  challenge.
      Often you just have to think about from an different point of view ;-)
      And in the end you can always ask an question at the  forum (but please take an clever
      description for the subject line and provide real examples of your file name, thanks.)





Find me: Renumbering Re-Numbering Exchange Numbers Serialize
Serializing Digits do the math reckoning calculation computation counting
     
.

5 (edited by Stefan 2017-06-01 12:04:20)

Re: Renumber starting with a number?

Q: How can I increase the "hour" by one in my file names?

FROM (here YYYYmmDDhhMMss.txt):
20170523064530.txt
20170523082330.txt
20170523101730.txt

TO (here increase hour by one each):
20170523074530.txt
20170523092330.txt
20170523111730.txt



A: Use two steps, combined in one command line, delimited by an semicolon.

---

First Expression: %b(1,8)_%b(9,2)_%f(11)


That means:
Give me first 8 signs, from 1 to 8 ("%b(1,8)"), from the BASE name (%b).
That is in this example the "YYYYmmDD"-part.

Next add an symbol (underscore here) to seperate the different digit-parts to let Siren find the wanted digit to adjust.
And also we say: give me two signs starting at position 9 = "_%b(9,2)" = the "hh"-part.

Again add an symbol (f.ex. underscore) and ask for all signs from pos. 11 till the end = ("_%f(11)")
(Note here we use "%f" for "whole file name" to include the extension too)

(interim) Result:
20170523_06_4530.txt
20170523_08_2330.txt
20170523_10_1730.txt

---

Instead of renaming with step 1 and re-load the files again, just add a semicolon
between both Expression, and Siren will do two calculation of new names for you "at once".

---

Second Expression: %N1_%N2{2,1}_%N3.*

(So the complete Expression is now:  %b(1,8)_%b(9,2)_%f(11) ; %N1_%N2{2,1}_%N3.*)


That means:
Give me the first found number (%N = "YYYYmmDD"-part = 20170523)
Add an symbol (f.ex. underscore) just to make the result most apparent (you can remove this afterwards)

Give me the second found number (%N2) and use modifier "{ p, v }" to do the math and increase the number by one.
(do you remember the modifier "{ p, v, n }"  for the number variable?
or more clearly: "{ padding width, value for calculation, pos of number to extract from the name }")

Next add an symbol and ask for third number (%N3), following by adding the original extension ( ".*" -or- "%e" )

(test) Result:
20170523_07_4530.txt
20170523_09_2330.txt
20170523_11_1730.txt

---

So the complete Expression is (see the semicolon ";" between "(11)" and "%N1"?)

%b(1,8)_%b(9,2)_%f(11);%N1_%N2{2,1}_%N3.*


or rather without the extra debugging symbols:
%b(1,8)_%b(9,2)_%f(11);%N1%N2{2,1}%N3.*

(real wanted) Result:
20170523074530.txt
20170523092330.txt
20170523111730.txt



Solved?
See you next time...


Press the F1-key while you are in Siren to read more about.
Enjoy Siren,  No installation needed, unzip and run. Siren stores it settings into an ini file, not in the Registry.
------------------------------------------------------------------------------------------------------------

                                             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

                                          Now for Windows Win32 and GNU/Linux also:
                                          http://scarabee-software.net/forum/viewtopic.php?id=273


.