Page 1 of 1

Add Zero's to the file to make 6 digit file name

PostPosted: Sat Dec 16, 2023 9:33 pm
by smartcard
I have a folder containing several image files, all starting with 'R-.' I would like to add leading zeros to the filenames to ensure they have a six-digit file name format.

In the following example, the first two filenames are correct, but for the remaining ones, I need to add the necessary zeros to achieve a six-digit filename. For instance:

    R-001057.jpg = good
    R-000058.jpg = good
    R-753.jpg = R-000753.jpg
    R-1054.jpg = R-001054.jpg
    R-1055.jpg = R-001055.jpg
    R-656.jpg = R-000656.jpg

Your assistance in this matter is appreciated

Pad "R-Digits" into "R-6Digits"

PostPosted: Sun Dec 17, 2023 3:37 am
by Luuk
To only rename jpg's, then Filters(12) could use something like *.jpg inside for the "Mask".
For 6-digits, Regex(1) needs a checkmark inside for "v2" with a "Match" and "Replace" like...
^(R-)(?=\d+$)(?X)(\G(?!^)|^R-)\K0(?=\d{6,}$)/g
${1}00000(?X)

R-1 ------------> R-000001
R-199 ---------> R-000199
R-00000009 --> R-000009
R-10000009 --> (not renamed)

Re: Pad "R-Digits" into "R-6Digits"

PostPosted: Sun Dec 17, 2023 4:12 am
by smartcard
Luuk wrote:To only rename jpg's, then Filters(12) could use something like *.jpg inside for the "Mask".
For 6-digits, Regex(1) needs a checkmark inside for "v2" with a "Match" and "Replace" like...
^(R-)(?=\d+$)(?X)(\G(?!^)|^R-)\K0(?=\d{6,}$)/g
${1}00000(?X)

R-1 ------------> R-000001
R-199 ---------> R-000199
R-00000009 --> R-000009
R-10000009 --> (not renamed)


Thank you so much! The process worked perfectly, just as expected

I need another help, how can I remove any characters between the last number in the file name and the extension as highlighted in the below image?
Image

Pad "R-digits" into "R-6Digits"

PostPosted: Sun Dec 17, 2023 5:12 am
by Luuk
Would need to edit the "Match" and "Replace" to something more like...
^(R-)(\d+).*(?X)(\G(?!^)|^R-)\K0(?=\d{6,}$)/g
${1}00000$2(?X)

R-1 ------------> R-000001
R-2Text -------> R-000002
R-199 ---------> R-000199
R-00000009 --> R-000009
R-10000009 --> (not renamed)