2

I have a Media Temple (dv) server which I am setting Magento up on.

I have uploaded a few thousand images to the /media/import directory that the client has provided me with. The problem is, some images are .jpg and others are .JPG.

Is there a way of batch renaming them on the server? I really don't want to have to do it locally and the re-upload them all.

I would ideally make them all lowercase so that they are uniform with the other image naming schemes used by Magento.

Thanks,

Danny

dannymcc
  • 2,747
  • 10
  • 49
  • 73

2 Answers2

3

A bash suggestion:

   for file in *.JPG; do newfile=`echo $file|sed 's/.JPG$/.jpg/'` ; mv -i "$file" "$newfile" ; done

It loops over all the files with a .JPG extension, and for each of them it uses sed to construct the new filename by turning a terminal .JPG into a terminal .jpg, and performs the mv. The -i is just in case you have a fred.JPG and a fred.jpg already. Don't forget to distinguish between single quotes and backticks, both of which are used, and aren't interchangeable.

MadHatter
  • 81,580
1

If you have the utility called rename installed (it's a Perl script) you can do:

rename 'y/A-Z/a-z/' *