Help - Search - Members - Calendar
Full Version: renaming files
Linuxhelp > Support > Technical Support
swbre
I had a bunch of files with filenames like DSCNnnnn.JPG where nnnn was a number between 3211 to 3271. I tried to change the name so the (caps) JPG would be lowercase jpg. I used
mv DSCN*.JPG DSCN*.jpg
and got an error message,
mv: target `DSCN*.jpg' is not a directory. I can do
mv DSCN3211.JPG DSCN3211.jpg
and that works ok. But I can't get the whole batch done with just one command. What am I doing wrong? How do I work around?
Thanks in advance.
michaelk
Assuming you do not have lots of files (meaning many hundreds) here is a quick bash script.

for file in *.JPG; do
mv "${file}" "${file%JPG}jpg"
done
swbre
QUOTE (michaelk @ Dec 8 2008, 10:15 PM) *
Assuming you do not have lots of files (meaning many hundreds) here is a quick bash script.


That works well. Thanks. How did you figure this out?
michaelk
Reading, doing, trial and error, many years of experience, ..... and of course googling smile.gif
http://linux.die.net/abs-guide/
http://www.faqs.org/docs/abs/HTML/string-manipulation.html
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.