I would like to rename all files in a folder so to have consecutive numbers. For instance:
1.png
2.png
3.png
etc
I know there is the rename command and I know there are DOZENS of similar questions in here but I can't find the way.
NOTE: Suggested duplicate doesn't contain a solution specific for my case. Please stop flagging this as duplicate, because suggested duplicate does not answer my question
Best Answer
Assuming you want to follow the shell globbing order while sorting files, you can do:
Here looping over all the files in the current directory and renaming sequentially based on order, if you want to deal with only the
.png
files, usefor file in *.png
instead.counter
variable will keep track of the increments.This is a dry-run, remove
echo
to let the actual renaming action take place.Example: