I am trying to batch-rename a bunch of files in my shell, and even though there is plenty of material about it on the internet, I cannot seem to find a solution for my specific case.
I have a bunch of files that have (what appears to be) a "timestamp-id":
abc_128390.png
abc_138493.png
abc_159084.png
...
that I'd like to exchange for a counter:
abc_001.png
abc_002.png
abc_003.png
...
My (plenty) naïve approach would be something like:
mv abc_*.png abc_{001..123}.png
Also, I could not figure out a way to make it work with a for
-loop.
FWIW, unfortunately rename
is not available on this particular system.
Any advice would be greatly appreciated!
abc_*.png abc_{001..123}.png
expands to the existing file names, and then the generated names in sequence, andmv
has no way to determine what the distinction between them is. (Try e.g.echo abc_*.png abc_{001..123}.png
) – ilkkachu Jan 31 '18 at 12:36