5,693,936 members and growing! (16,815 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code License: The Code Project Open License (CPOL)

JPGDateChanger - Tool to Restore Last Modified Date for JPG Files

By Damir Valiulin

JPGDateChanger is a tool that changes last modified date to the one stored in EXIF data
C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, Windows, Visual Studio, MFC

Posted: 2 Aug 2008
Updated: 2 Aug 2008
Views: 4,410
Bookmarked: 4 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
4 votes for this Article.
Popularity: 1.98 Rating: 3.29 out of 5
1 vote, 25.0%
1
0 votes, 0.0%
2
1 vote, 25.0%
3
0 votes, 0.0%
4
2 votes, 50.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article
jpgdatechanger.jpg

Introduction

JPGDateChanger is a tool that changes last modified date of a JPG file to match the date extracted from Date Taken field in file's EXIF tag.

Background

Often after transferring images from my digital camera I quickly go through them and fix the orientation on pictures taken in portrait mode. On my XP machine I simply use the built in Windows Picture and Fax Viewer to do the job. On my Vista machine this program was replaced with Windows Photo Gallery. The new 'feature' of the Vista's replacement is that clicking on Rotate button sets the "Date Modified" to current time. I find this behaviour really annoying, since I usually sort my pictures in the folder by date.

After screwing up the dates on some pictures for the N-th time (being forgetful), I tried to find the tool on Internet that would change the date back by extracting it from EXIF tag. Unfortunately I found only some all-in-one utilities, all bloated and all shareware.

Well, it shouldn't be too hard to write one myself, I thought. Turned out it was dead simple. Immediately on Codeproject I found Davide Pizzolato's article CExif, and in 15 minutes, after modifying his example, I had a working program! The other 4 hours went into polishing its look ;-)

Usage

To use the tool, simply drop JPG files on the main window and their dates will be automatically updated. The files must have extension JPG or JPEG. If the some image files don't have EXIF tag, or the date stored in the EXIF is the same as last modified date, no action will be taken on those files.

I added "Keep Window on Top" option for convenience and this preference is stored in the Windows Registry.

About the code

For details on reading EXIF from jpg files see Davide Pizzolato's article CExif. To change the date I simply use MFC's CFile::GetStatus and CFile::SetStatus functions:

CFileStatus fs;
if (CFile::GetStatus(fname, fs))
{
   CTime t_new (d_yyyy, d_mm, d_dd, t_hh, t_mm, t_ss);
   fs.m_mtime = t_new;
   CFile::SetStatus(fname, fs);
}

Links

Here's all the links to other people's work that I used to create this tool.

http://www.codeproject.com/KB/graphics/cexif.aspx Davide Pizzolato's Cexif class to read EXIF data from JPG images
http://www.codeproject.com/KB/system/registry.aspx Robert Pittenger's simple registry class
http://www.codeproject.com/KB/static/XColorStatic.aspx Hans Dietrich's XColorStatic class to make the window look a little less boring
http://www.icojoy.com/articles/19/ I used one of the free icons made by Andrew Zherbakov as my main app icon.

History

  • 2008-08-02, v1.0 - Initial posting to Codeproject
  • 2008-08-07, v1.1 - Added combo box that allows user to choose which date to correct: Date Modifed, Date Created, or both

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Damir Valiulin



Occupation: Software Developer
Location: Canada Canada

Other popular Applications & Tools articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh)FirstPrevNext
GeneralGreat softwarememberroadbug14:26 14 Sep '08  
GeneralHow many files in one go?memberCurt Henning de Thurah13:23 12 Aug '08  
GeneralRe: How many files in one go?memberDamir Valiulin19:56 15 Aug '08  
GeneralHow about Date Created?memberKent K13:14 5 Aug '08  
GeneralRe: How about Date Created?memberDamir Valiulin15:04 5 Aug '08  
GeneralRe: How about Date Created?memberKent K5:59 6 Aug '08  
GeneralRe: How about Date Created?memberDamir Valiulin6:58 7 Aug '08  
GeneralGreat Job!memberchaau17:42 4 Aug '08  
GeneralRe: Great Job!memberDamir Valiulin5:04 5 Aug '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 2 Aug 2008
Editor: Sean Ewington
Copyright 2008 by Damir Valiulin
Everything else Copyright © CodeProject, 1999-2008
Web09 | Advertise on the Code Project