Pad / Fill a numeric (or otherwise) value

Would you like Bulk Rename Utility to offer new functionality? Post your comments here!

Pad / Fill a numeric (or otherwise) value

Postby therube » Thu May 11, 2023 6:05 pm

Pad / Fill a numeric (or otherwise) value.

Maybe could be incorporated into 10:Numbering.

So if you had:

Code: Select all
57
0001
0002

And you wanted to Pad the "numbers" to 4 digits, you would get:
Code: Select all
0057
0001
0002

Theoretically speaking, you could use something like:

10:Numbering
Code: Select all
Mode: Pad
Start: 0
Incr: 0
Pad:4


And that says, do not increment any numbering,
simply Pad the number with, in this case, zeros
(such that the resulting numbers are 4-characters in length, padded by zeros).
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Pad / Fill a numeric (or otherwise) value

Postby therube » Thu May 11, 2023 6:09 pm

>LIST
Code: Select all
0010 REM     "pad"                                 
0020 REM                                           
0030 REM "pad" with zeros @ the front of a variable
0040 REM     for non subscripted variables         
0050 REM                                           
0060 ENTER X$,LENGTH                               
0070 IF LEN(X$)<LENGTH THEN DIM ZERO$(LENGTH,"0") 
0075 LET X$=ZERO$(1,LENGTH-LEN(X$))+X$             
0080 REM                                           
0090 END                                           

>x$="testing123"
>call "pad",x$,18
>print x$
00000000testing123

Similarly, fill:

>LIST
Code: Select all
0010 REM    "fill"                                       
0020 REM                                                 
0030 REM   "fill" with blank spaces at the end of variable
0040 REM                                                 
0050 ENTER X$,LENGTH                                     
0060 REM                                                 
0070 IF LEN(X$)<LENGTH THEN DIM FILL$(LENGTH," ")         
0075 LET X$=X$+FILL$(1,LENGTH-LEN(X$))                   
0080 REM                                                 
0090 END                                                 
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Pad / Fill a numeric (or otherwise) value

Postby dec » Sun May 14, 2023 5:34 am

therube wrote:Pad / Fill a numeric (or otherwise) value.

Maybe could be incorporated into 10:Numbering.

So if you had:

Code: Select all
57
0001
0002

And you wanted to Pad the "numbers" to 4 digits, you would get:
Code: Select all
0057
0001
0002

Theoretically speaking, you could use something like:

10:Numbering
Code: Select all
Mode: Pad
Start: 0
Incr: 0
Pad:4


And that says, do not increment any numbering,
simply Pad the number with, in this case, zeros
(such that the resulting numbers are 4-characters in length, padded by zeros).


again, unless i miss someting at first glance, i do not see anything that the existing Numbering Panel can not do easily
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Padding numbers and/or words

Postby Luuk » Sat May 20, 2023 8:34 pm

I think that Mode==Pad can be a great solution, but it should probably only conduct names with having all numbers?
Right now, it does seems like Numbering(10) does only conducts against a variable something like %autonumber%.
So when clicking Mode==Pad, it could just switch variables something like... %autonumber% ---> %name%.

But this could be a problem, for users with having names something like... "1 of 200 speeches from 5-9-2019".
So the programmers would need to invent some file-format verifications, for which of these numbers to pad?
Probably the easiest way to implement, is to just conduct the names with having all numbers.

Or maybe let users also specify a custom-format like..... "pad:3 of pad:none speeches * pad:2-pad:2-pad:none".
So then it would verify %name% against something like... "^\d+ of \d+ speeches .* \d+-\d+-\d+$".
And after the verification, then to conduct padding at all of the different places.

Another thing that Im thinking, is maybe to pad all of the numbers with something like... "pad:all:4".
Then it doesnt even need to verify against %name%, because conducting something like... "\b\d+\b/g".
This really is just me guessing a lot, because Im not know any of the true programming languages.

The only other thing Im thinking, is maybe to pad words like... pad:9:i so then padding "word"--->"iiiiiword".
But if Im the programmer, Im wanting padw: for padding the words, and pad: for padding only the numbers.
Of course the regex and javascript can conduct all of this, but its too complicated for many users.

www.bulkrenameutility.co.uk/forum/viewt ... 100#p16913 pads names into 12-digits, but its only for names with all numbers.
If you have any other custom-formats the forum can always help, so it should not be very hard to modify.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Pad / Fill a numeric (or otherwise) value

Postby Admin » Mon May 22, 2023 12:16 am

Maybe an option to pad existing numbers that are present in the name could be to add a specific function in RegEx (1)
For instance with Simple RegEx

Match: %1
Replace: %1(pad3)

Match: %1 - %2
Replace: %1(pad3) - %2(pad10)

But would need to work out the best syntax
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm


Return to Suggestions