I have a number of home video files in different directories that have a year at the end of the directory name to indicate the year that the video was filmed. It is also at the end of the filenames in that directory and before the extension. I want to put parentheses around the year.
Some files and directories may also have a year (or numbers that look like a year) in the filename in other positions, but I just want to put parenthesis around the year at the end. For example here is one of the directories:
Videos/Xmas 2004 - Time To Go 2004
contains:
Xmas 2004 - Time To To 2004.mp4
Xmas 2004 - Time To Go 2004.txt
Xmas 2004 - Time To Go 2004.readme
I want to bulk rename all my media files to end up with this naming system:
Videos/Xmas 2004 - Time To Go (2004)
contains
Xmas 2004 - Time To To (2004).mp4
Xmas 2004 - Time To Go (2004).txt
Xmas 2004 - Time To Go (2004).readme
How do I do this? I can use the "find" command to get the files and directories:
find /home/user/Videos/ -iname "* [1-2][0-9][0-9][0-9]" # Find directories
find /home/user/Videos/ -iname "* [1-2][0-9][0-9][0-9].*" # Find files
I am wondering how I can use the "-exec {} \;" structure to use the rename or mv command (or sed or awk) or do I write a bash script to manipulate the filename string and put that in the "-exec {} \;"