how can I get Ubuntu 10.10 to give photos lower case file extentions

Asked by Ralph Rudd on 2011-03-28

Ubuntu 10.10 gives photos upper case file extensions when they are uploaded from the camera i.e. .JPEG
How can I make it give lower case file extensions ie. .jpeg when photos are uploaded.
What do I need to change and where. I am not very experienced at changing code etc in the folders.
The reason I need to do this is because many of the bulk file up loaders on the internet such as ebay, facebook etc look for lower case file extensions. If the extension is in upper case they can't see it and show a blank page when you browse to the final date page

NOW SOLVED SEE BELOW

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Ralph Rudd
Solved:
2011-07-19
Last query:
2011-07-19
Last reply:
2011-03-29
delance (olivier-delance) said : #2

for f in `ls *.JPEG`; do b=`basename $f .JPEG`; mv $b.JPEG $b.jpeg; done

same in bash

Doesn't take into account spaces in files.

You should add quotes

Ralph Rudd (ralf1erudd) said : #4

Hello guys thank for the help But I am at a loss for what to do with this stuff (I did say I wasn't good at it)
Do I paste it in terminal or what
I tried to paste both in terminal and it came back with syntax error messages so i am still at a loss for what to do
Regards ralph

Yes they are bash scripts

delance (olivier-delance) said : #6

actionparsnip is right. Try first his solution. If you need, I will verify mine.
I think it should be:
for f in `ls *.JPEG`; do b=`basename $f .JPEG`; mv "$b.JPEG" "$b.jpeg"; done
Don't retype but do a copy/paste. For terminal, paste is Shift+Ctrl+V

Hi Ralph Rudd and all the others,

what about rename, its available by default and it's easier to understand

The proposal by actionparsnip with rename would be:

rename 's/\.JPEG$/.jpeg/' *.JPEG

If you want to lowercase the full name and not just the file extension:

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

Also rename has a trial mode using the flag --no-act just to show what would have done if you are unsure to procceed, ie:

hmontoliu@ulises:/tmp/foo$ rename --no-act 's/\.JPEG/.jpeg/' *.JPEG
a.JPEG renamed as a.jpeg
asdf.JPEG renamed as asdf.jpeg
awer.JPEG renamed as awer.jpeg
dafdf.JPEG renamed as dafdf.jpeg

HTH

--
hmontoliu <at> ubuntu.com
http://hmontoliu.blogspot.com

Ralph Rudd (ralf1erudd) said : #8

Hello, I will try to put each one in terminal and paste you the results of what it does
1st actionparsnip solution which I may have got wrong anyway by not understanding
ralph@ralph-P4M890T-M ~ $ #!/usr/bin/perl
ralph@ralph-P4M890T-M ~ $ $files=`ls`;
=Desktop: command not found
ralph@ralph-P4M890T-M ~ $ @files=split(/\n/,$files);
bash: syntax error near unexpected token `/\n/,$files'
ralph@ralph-P4M890T-M ~ $
ralph@ralph-P4M890T-M ~ $ foreach (@files) {
bash: syntax error near unexpected token `@files'
ralph@ralph-P4M890T-M ~ $ if(/(.*)\.(a.+)$/) {
bash: syntax error near unexpected token `.*'
ralph@ralph-P4M890T-M ~ $
ralph@ralph-P4M890T-M ~ $ $name=$1."."."\L$2\E";
=...\L\E: command not found
ralph@ralph-P4M890T-M ~ $
ralph@ralph-P4M890T-M ~ $ system("mv $_ $name")
bash: syntax error near unexpected token `"mv $_ $name"'
ralph@ralph-P4M890T-M ~ $ }
bash: syntax error near unexpected token `}'
ralph@ralph-P4M890T-M ~ $ }

2nd the delance solution
ralph@ralph-P4M890T-M ~ $ for f in `ls *.JPEG`; do b=`basename $f .JPEG`; mv "$b.JPEG" "$b.jpeg"; done
ls: cannot access *.JPEG: No such file or directory
ralph@ralph-P4M890T-M ~ $

3rd (hjmf) solution which I may also have got wrong not knowing if it should stand alone or be grafted into the first one
ralph@ralph-P4M890T-M ~ $ rename 's/\.JPEG$/.jpeg/' *.JPEG
Can't rename *.JPEG *.jpeg: No such file or directory
ralph@ralph-P4M890T-M ~ $
 As you can see either I have misunderstood all that you are all telling me or I have not explained the problem properly.
Thank you all so much for your persistence Ralph

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El 29/03/11 18:38, Ralph Rudd escribió:
> 3rd (hjmf) solution which I may also have got wrong not knowing if it should stand alone or be grafted into the first one
> ralph@ralph-P4M890T-M ~ $ rename 's/\.JPEG$/.jpeg/' *.JPEG
> Can't rename *.JPEG *.jpeg: No such file or directory
> ralph@ralph-P4M890T-M ~ $
> As you can see either I have misunderstood all that you are all telling me or I have not explained the problem properly.
> Thank you all so much for your persistence Ralph

Hi, Ralph

you need to run those comands in the folder which have files with JPEG
extensions.

Lets say you have placed those photos in a folder named PHOTOS which is
located in your desktop and lets say your user is named "ralph"; Then
the steps you'll need to follow to run the reneame command there are:

Lets change to that directory (folder), adapt the path to your situation:

cd /home/ralph/Desktop/PHOTOS

Lets see if there are any JPEG files:

ls *.JPEG

If ls lists any JPEG file, then you are in the right place.

Finally run the rename command:

rename 's/\.JPEG$/.jpeg/' *.JPEG

- --
Hilario J. Montoliu
hmontoliu <at> ubuntu.com
http://hmontoliu.blogspot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2SEfwACgkQk9xSKJO/Y0EaEACgmkAP1YsgeAufNMV8J3wqA/Ie
YhsAn0iLV1Fg2RtpnH7XdOZmgfr8aZVs
=yQap
-----END PGP SIGNATURE-----

The code you pasted is a SCRIPT. If you run:

sudo apt-get install perl; gksudo gedit /usr/bin/maxextension; sudo chmod +x /usr/bin/maxextension

Paste the script into the file, save the file and close gedit. You can now simply change directory in terminal to the one you want to manipulate and run:

maxextension

And the files will be fixed

Ralph Rudd (ralf1erudd) said : #11

The code you pasted is a SCRIPT. If you run:

sudo apt-get install perl; gksudo gedit /usr/bin/maxextension; sudo chmod +x /usr/bin/maxextension

Paste the script into the file, save the file and close gedit. You can now simply change directory in terminal to the one you want to manipulate and run:

maxextension

And the files will be fixed
Right I have done up as far as saving the file and close gedit. At that point you lost me
Just to clarify what I want to do.
Ubuntu used to automatically give lower case extensions to jpeg files a couple of versions ago.
Now for some reason during the writing of the new packages some one has managed to get Ubunto 10 to automatically give upper case extensions to .JPEG files just like that!
With a slip or blunder of the keyboard. The result is that lots of bulk file uploaders don't recognise the upper case file extensions so as far as the uploader is concerned they don't exist.
I can go through the 100's of pictures I put into these computers every week and rename them with a lower case extension one by one.
But what I am trying to achieve here is an answer for myself and all the other poor people on these forums who have been trying to get their photos on the web the way they used to be able to.
What I am looking for is to change the mistyping or whatever is was, so that ubuntu will once again give lower case file extensions to the photos as they are saved to the hard drive from the camera.
I assume off course that the file system itself gives the photos their number and file extension rather than the camera. I believe it must be so because the older version still gives lower case file extensions.
Somewhere in the system is a file or piece of code that tells the file system to give all incoming photos an upper case file extension rather than a lower case one that will be recognised.
We need to file that file or piece of code and change it so that it knows the difference between .JPEG and .jpeg
I hope that helps clarify what I am asking you guys to find.
I am sorry I was not clear enough earlier.

Ralph Rudd (ralf1erudd) said : #12

Hello all and thank you for your efforts. I have at last found a simple solution for this problem without having to change folders etc.
Install shotwell on the system
It has a tick box in it's setup menu to mark incoming photos extensions in lower case as it imports them.
I found out it is certain cameras that upload upper case extensions and shotwell puts this right