Zambini’s Photos A Beginning Photo Blog

5Jul/100

Workaround for Ubuntu and Nautilus’s capital .JPG issue

Hey All!

I just wrote a little ditty on LaunchPad regarding an issue I had uploading images to multiple-image uploader sites (like Facebook).

I use Ubuntu (10.04) Linux primarily on this machine and Google Picasa to organize my photos and choose which ones to export, and when it does, it outputs them to "filename.JPG". This is a problem, however, because for some reason with Nautilus and sites like Facebook where you can upload multiple image files, it doesn't like having the .JPG in capitals.

Wait a minute, there are 50 or so images in there =O

Strange, yes. Unsolvable? No. Even though the LaunchPad bug has been semi-ignored and marked a low priority, Linux is awesome, and the fix is an incredibly simple set of commands in a terminal and then all it is from then on is a matter of running one custom script.

If you're only doing this once, or have a REALLY REALLY good memory, this is all you have to do:

1) Navigate to the folder all your pictures are in using the 'change directory' command

cd /home/USERNAME/Folder_where_your_pictures_are

2) Run this simple shell script:

for i in *.JPG; do mv "$i" "`basename $i .JPG `.jpg"; done

What this command does is does a simple for loop, iterating over each of the files that end with ".JPG" and re-names them to end in ".jpg".

If you want to be super awesome and efficient (aka: lazy), you can write this into a custom script so all you have to do is cd into the directory and type in the name of your script. Here's how to do it:

1) Navigate into your bin directory. I used /usr/bin. (There are people who might chastise me for not putting it in /usr/local/bin, but I don't really care. Feel free to explain to me why I should put it there in comments, but don't want a flame war.)

cd /usr/bin

2) Make a new script. You'll have to do it as a super user. I personally love pico, but you can use ANY text editor that doesn't throw any nasty formatting in anywhere. Here, I named my script "JPGtojpg" which is very easy to remember, and not many commands start with J, so in bash I can just hit a capital J and then hit <TAB> and it'll type the rest for me :) (remember when I said lazy? ;P )

sudo pico JPGtojpg

3) Make the contents of this script file as follows:

#!/bin/bash
for i in *.JPG; do mv "$i" "`basename $i .JPG `.jpg"; done

4) Save the file, and then change it to be executable. Again, must sudo it

sudo chmod +x JPGtojpg

5) You're done!

Now you can just cd into the directory where all those .JPG files are and type in "JPGtojpg" in the command line and it will fix them for you!

It's ALIVE! MUAUAHAHAHA!

Oh look, my photos! :D

A big thanks to Steve at Debian-Administration.org for the for loop. If you want an expert's explanation of this script, go to his post about it here.