I was testing/trying out this Perl one-liner, and I'm trying to figure out what happened to the files. I don't see the files anymore. Did I delete them or what went wrong?
Example of file names listed (original):
IMG_0178.JPG
IMG_0182.JPG
IMG_0183.JPG
IMG_0184.JPG
IMG_0186.JPG
I wanted to simply change the file extension to lowercase (.jpg):
perl -e'while(<*.JPG>) { s/JPG$/jpg/; rename <*.jpg>, $_ }'
Don't use rename
with a glob. Use scalars. Try to assign the file name to a new variable before the substitution and rename the old name to the modified one, like this:
perl -e'while(<*.JPG>) { ($new = $_) =~ s/JPG$/jpg/; rename $_, $new }'
Check output with ls -1
:
IMG_0178.jpg
IMG_0182.jpg
IMG_0183.jpg
IMG_0184.jpg
IMG_0186.jpg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With