I have recently discovered this technique for renaming files using
autoload zmv zmv '(*).JPG' '$1.jpg'
which I can also write as:
autoload zmv; zmv '(*).JPG' '$1.jpg'
This works as advertised and I can use it to change the Upper Case
JPG extension to lower case.
However, I would like to run this as a one-liner from my usual BASH shell. When I try to call it as follows:
zsh -c "autoload zmv; zmv -f '(*).JPG' '$1.jpg'"
echo 'autoload zmv; zmv -f "(*).JPG" "$1.jpg"' | zsh -i
I get something like the following message
zmv: error(s) in substitution: ….JPG and ….JPG both map to .jpg
This suggests to me that that
zsh is treating the file names case-insensitively, but that does not appear to be the case when run the first way.
Obviously, I don’t know what I’m doing here. I have also tried reversing the single and double quotes in case shell expansion is getting in the way.
How can I run this command as a one-liner from bash?