Who Needs to Be Able to Program a Computer?

I have been trying to organize my collection of digital photos. It goes back to 1999 when I had some film photos put on CDs when they were developed. I now have over 1400 photos that take up 1.6 GB. I need to back up all of these photos and set things up so that I can continue to easily back them up. I decided that it would be good to upload them all to the new Yahoo Photos website. Yahoo Photos stores the full resolution pictures and lets me download the full resolution pictures later. It supports tags like Flickr. It is free and I have not found a limit to the amount of space I can use.

I ran into two problems when I started. One is that the upload dialog on linux did not recognize .JPG files as photos. It was looking for .jpg. My current camera, Nikon D50, produces files with the .JPG extension. The other is that my camera does not produce unique names for each file. If I deleted all pictures from the camera, it starts counting again from DSC_001.JPG. I was not going to use the same directory structure on Yahoo Photos. I was just going to upload them all in one big pile and tag them.

I needed to fix the names of the files. I decided to rename each file based on its directory name and fix the case of the extension. I could not think of anyway of doing this except by hand or writing a program.  I ended up writing a python program to do it. It is only about 20 lines long. It took me awhile since I had to consult my manual several times. Still it was faster to write, debug, and then run this program than do rename all of the files by hand.

What made this possible is the fact that I do have a large amount of programming experience even if most of it is not recent. I was slow but I knew what I was doing.


5 Responses to “Who Needs to Be Able to Program a Computer?”

  1. Hey – I don’t have extensive programming experience, but the fact that you can write 20 lines of Python to do that is pretty neat. You’ve inspired me to now go and learn Python.
    Can you post a reply comment with your 20 lines of Python code? Thanks!

  2. I do not seem to be getting my notifications of comments. I just saw your comment.

    I had some trouble getting the formatting right. The last four lines should be indented.

    import os
    import glob
    import shutil
    images = glob.glob("*.jpg") + glob.glob("*.JPG")
    base = os.path.basename(os.getcwd())
    # Replace spaces with underscores
    name=base.replace(" ","_")
    count = 0
    for image in images:
    count = count+1
    new_name = "/media/usbdisk/photos/"+name+"_"+`count`+".jpg"
    print image, new_name
    shutil.copyfile(image, new_name)

  3. If my impression is correct and you are using Ubuntu then I can recommend 2 time saving batch rename options (if you haven’t come across them yet): PrefixSuffix (added from your AddRemoved menu) is a handy renaming utility; also gThumb (a popular photo manager) has built-in renaming (select several thumbs and press F2 to get options).

  4. Is definitely a genuinely excellent entry, thank you very much. I have bookmarked this site to my personal favourites list.

  5. Great Blog! I have a similar site, and acquire a lot of spam. Do you face such problems? Can you please recommend some steps I take to combat spam. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: