I want to rename the files in a directory to sequential numbers. Based on creation date of the files.
For Example sadf.jpg
to 0001.jpg
, wrjr3.jpg
to 0002.jpg
and so on, the number of leading zeroes depending on the total amount of files (no need for extra zeroes if not needed).
Here a another solution with "rename" command:
Pero's answer got me here :)
I wanted to rename files relative to time as the image viewers did not display images in time order.
This oneliner lists all files in the current directory, sorts by creation timestamp in reverse order (means the oldest file is at the beginning) and renames automatically with trailing zeros as required by the amount of files. The file extension will be preserved.
I usually have only one folder since years for mobile phone pictures and movies. Applying this command, my pictures and movies are ready then for a slideshow in the correct order on the tv or archiving as well.
Be aware that if you have file name collisions, you are losing files. So first rename to something odd like
temp001.jpg
and then execute to your final file name.Beauty in one line
change extension with desired PNG, Jpg or some-other.
A very simple bash one liner that keeps the original extensions, adds leading zeros, and also works in OSX:
Simplified version of http://ubuntuforums.org/showthread.php?t=1355021