Command to change string within folder and file names recursively in Mac OS X

I wanted to rename a whole load of .mkv video files and the folders they were contained within. They all contained the string 1080p and I wanted to change it to 1080P. Notice that the difference is simply the case of the letter P in 1080p, I wanted it to be a capital P. To illustrate this I setup 4 folders; Test1 (1080p), Test2 (1080p), Test3 (1080p) & Test4 (1080p). These folders all contained 1 .mkv file each, also containing the string 1080p. A tree output of the folder structure is below:

|____Test1 (1080p)
| |____Test1 (1080p).mkv
|____Test2 (1080p)
| |____Test2 (1080p).mkv
|____Test3 (1080p)
| |____Test3 (1080p).mkv
|____Test4 (1080p)
| |____Test4 (1080p).mkv

After trying various different commands and failing, I found the answer here. It is the 3rd command on the page by l’L’l:

I changed it according to my needs and ran the command below in the root folder of the folders and files I wanted to rename:

find . -name '*1080p*' | while read f; do mv "$f" “${f//1080p/1080P}"; done

The result was as expected, all folders and files were renamed to contain the string 1080P:

|____Test1 (1080P)
| |____Test1 (1080P).mkv
|____Test2 (1080P)
| |____Test2 (1080P).mkv
|____Test3 (1080P)
| |____Test3 (1080P).mkv
|____Test4 (1080P)
| |____Test4 (1080P).mkv

Be careful when running this command as it will recursively go through all sub-folders and rename anything that matches your string parameters.

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.