Write a simple script that will automatically rename a number of files. As an example we want the file *001.jpg renamed to user defined string + 001.jpg (ex: MyVacation20110725_001.jpg) The usage for this script is to get the digital camera photos to have file names that make some sense.
I need to write a shell script for this. Can someone suggest how to begin?
An example to help you get off the ground.
In this example, I am assuming that all your image files contain the string
IMGand you want to replaceIMGwithVACATION.The shell automatically evaluates
*.jpgto all the matching files.The second argument of
mv(the new name of the file) is the output of thesedcommand that replacesIMGwithVACATION.If your filenames include whitespace pay careful attention to the
"$f"notation. You need the double-quotes to preserve the whitespace.