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..)
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
an automated way to [ pad the numbered files ]
(converting 1.png, 2.png, 10.png to 001.png, 002.png, 010.png,
etc..)
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.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 299 |
Nodes: | 16 (3 / 13) |
Uptime: | 64:55:36 |
Calls: | 6,691 |
Calls today: | 1 |
Files: | 12,228 |
Messages: | 5,345,756 |
Posted today: | 1 |