Topic: Add a leading zero to existing numbers
I want to add a leading zero to existing numbers
Q: I have some picture named
pic1.jpg
pic2.jpg
pic3.jpg
[...]
pic10.jpg
pic11.jpg
Now i want to have all names with two digits by adding an leading zero to the first 9 files.
A: That's easy with Siren
Use Ctr+B to choose your directory. Single click on it and choose OK
You can use the filter combo box to see only files you want to.
e.g. use pic?.jpg if you want to see only files with one char only between 'pic' and '.jpg'
EXAMPLE: pic1.jpg
EXPRESSION: %NN\0%N.*
RESULT: pic001.jpg
Thats not completely what we want.
That's because what we see is an default in Siren.
Go to "Files\Options" or use Ctrl+O
Now go to "Numbers"
Decrease the '3' by "Number contained in base file name" to '1'
Now our result is
RESULT: pic01.jpg
EXPLANATION:
%NN : a non numeric string contained in the base file name a digit can indicate its position (1 by default) [pic]
\0 : adding an zero (we must escape the digit 0 to avoid that %NN will catch the zero as parameter) [pic0]
%N : a number contained in the base file name a digit can indicate its position (1 by default) [pic01]
. : an DOT [pic01.]
* : the * means here the extension [pic01.jpg]
Note: Depending upon the position of the '.' (the dot which delineates file base name from extension) in an expression, the '*' will represent either the base name or the extension.
You can solve most of your renaming problem with Siren in different ways.
For example you could use this too
EXPRESSION: %f(s/(\d)/0\1/)
EXPLANATION:
%f : Siren: the hole file name
(s/ : RegEx: start search and find what follows
(\d) : RegEx: search for an single digit AND group it for backreference
/ :RegEx: end the search and interpret the following as the replacement
0 :RegEx: simply an zero
\1 :RegEx: insert here that what is found in the first group ()
/) :RegEx: end search and replace
Press the F1-key while you are in Siren to get some help.
------------------------------------------------------------------------------------------------------------
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