• automated way to fix unpadded numbering?

    From candycanearter07@21:1/5 to All on Mon Sep 11 02:40:41 2023
    Hi,
    I'm having an issue with a program not having an option to pad the
    numbered files when exporting. It's "relatively" easy to fix with vidir
    and using vim macros, but I was wondering if there was an automated way
    to do it?

    (converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png, etc..)
    --
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David W. Hodgins@21:1/5 to no@thanks.net on Mon Sep 11 04:23:29 2023
    On Mon, 11 Sep 2023 03:40:41 -0400, candycanearter07 <no@thanks.net> wrote:
    Hi,
    I'm having an issue with a program not having an option to pad the
    numbered files when exporting. It's "relatively" easy to fix with vidir
    and using vim macros, but I was wondering if there was an automated way
    to do it?

    (converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png, etc..)

    The man page for the rename command gives the following example ...
    Given the files foo1, ..., foo9, foo10, ..., foo278, the commands

    rename foo foo00 foo?
    rename foo foo0 foo??

    will turn them into foo001, ..., foo009, foo010, ..., foo278.

    The rename command is part of the package util-linux.

    Regards, Dave Hodgins

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to David W. Hodgins on Mon Sep 11 07:44:17 2023
    On 9/11/23 03:23, David W. Hodgins wrote:
    On Mon, 11 Sep 2023 03:40:41 -0400, candycanearter07 <no@thanks.net> wrote:
    Hi,
    I'm having an issue with a program not having an option to pad the
    numbered files when exporting. It's "relatively" easy to fix with vidir
    and using vim macros, but I was wondering if there was an automated way
    to do it?

    (converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png, etc..)

    The man page for the rename command gives the following example ...
           Given the files foo1, ..., foo9, foo10, ..., foo278, the commands

                  rename foo foo00 foo?
                  rename foo foo0 foo??

           will turn them into foo001, ..., foo009, foo010, ..., foo278.

    The rename command is part of the package util-linux.

    Regards, Dave Hodgins

    You're a lifesaver, Dave.

    --
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Fritz Wuehler@21:1/5 to All on Tue Sep 12 05:53:54 2023
    candycanearter07 <no@thanks.net> [c]:
    an automated way to [ pad the numbered files ]

    (converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png,
    etc..)

    printf(1) is your friend:


    for i in *png;do x=$(printf "%03d.png" "${i/.png}");echo mv -v "$i" "$x";done


    This command only demonstrates what will be done; remove 'echo' to
    actually do it.

    If you have like thousands of such files, the for loop above may fail
    (the argument expansion will exceed some shell limit).
    If that's the case, then use 'xargs(1)' or 'parallel(1)' instead.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Fritz Wuehler on Mon Sep 11 23:25:20 2023
    On 9/11/23 22:53, Fritz Wuehler wrote:
    candycanearter07 <no@thanks.net> [c]:
    an automated way to [ pad the numbered files ]

    (converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png,
    etc..)

    printf(1) is your friend:


    for i in *png;do x=$(printf "%03d.png" "${i/.png}");echo mv -v "$i" "$x";done


    This command only demonstrates what will be done; remove 'echo' to
    actually do it.

    If you have like thousands of such files, the for loop above may fail
    (the argument expansion will exceed some shell limit).
    If that's the case, then use 'xargs(1)' or 'parallel(1)' instead.


    Thanks

    --
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)