I am trying to write a bourne-shell script that takes a directory as a parameter and look for images named ixxx.a and rename them to ixxx_a.img where “xxx means the extension number for exemple image files would be named i001.a , i002.a ,i003.a …)
here what I tried
mv $1/f[0-9][0-9][0-9].a $1/f[0-9][0-9][0-9]_a.img
but it says that the DEST is not a directory.
Any help would be much appreciated. Thanks.
However, this does not consider blank spaces in the file/folder names. In this case you’d have to use
whileso you get one file name per line (see below for bonus). There are probably dozens of other ways, includingrename.Edit: Perhaps I should explain what I did there. It’s called string substitution and the main use cases are these for a variable
var:For more see the
manpage.