I've got a bunch of files with names like image(1) image(2) image(3) . I'd like to rename those en masse along the lines of image1.jpg image2.jpg etc. I can do it in two steps by means of curly braces , which apparently is some sort of built-in shell provision for string replacement along the lines of
orig="a_string"
mod=${orig/string/new_thing}
which takes a_string to a_new_thing. So using that in a for loop I can take care of turning the ) into .jpg
for f in *; do mv $f "${f/)/.jpg}" ;done
and then
for f in *; do mv $f "${f/\(/}" ;done
removes the (. The open paren has to be escaped , I suppose as otherwise the shell thinks its the start of something else. The close paren doesn't have to be escaped like that. So my question is , is there a one-liner or other better way to do this, like using pipes. If the parens in the filename are mucking things up then assume for the time being these parens are removed , leaving the bare problem of replacing two substrings with two other strings .