Command to rename files according to creation date on Mac OS X

Someone might find this command useful, it renames files in the current directory according to their respective creation dates:

I found this link and modified the command per the below:

for i in *; do newname=$(stat -t %Y%m%d%H%M%S -f %Sm -- $i); mv -- $i $newname; done

I used it to rename .jpg screenshots that I created before uploading them to WordPress to ensure strict uniform file naming convention. To do that I ran:

for i in *.jpg; do newname=$(stat -t %Y%m%d%H%M%S -f %Sm -- $i); mv -- $i $newname.jpg; done

Hopefully this may save someone a few dollars as you won’t need to buy some of those Mac file renaming applications just to rename files according to creation date.