Timestamp digital pictures

I was given several dozen digital photos that I wanted to add to my collection. However, the camera used did not have the date/time set. Worst still, each time the camera was turned on, the camera clock started ticking from the same time (1/1/2004 midnight).


With certain display modes of my picture display program and screen saver, the pictures are sorted by date/time stamp order. However, because these pictures were from several events, the pictures appeared to be in a random order. In fact, they were in date/time order, so the first picture displayed was the one closest to the time of the camera power on, and the last was the one with the camera on the longest.


I wrote a simple program to adjust the file timestamps to be at least in chronological order based on the picture sequence number, which was chronological. Of course, this did not change the Exif JPG picture properties directly stored inside the JPG file.


See also:

Draw text or graphics directly onto a JPG file

Sharing Digital Pictures of your friend's

Make an interactive screen saver






FOR i = 1 TO n








*From WINNT.H:

#define FILE_SHARE_READ                 0x00000001 

#define FILE_SHARE_WRITE                0x00000002 

#define FILE_SHARE_DELETE               0x00000004 

#define FILE_ATTRIBUTE_READONLY             0x00000001 

#define FILE_ATTRIBUTE_HIDDEN               0x00000002 

#define FILE_ATTRIBUTE_SYSTEM               0x00000004 

#define FILE_ATTRIBUTE_DIRECTORY            0x00000010 

#define FILE_ATTRIBUTE_ARCHIVE              0x00000020 

#define FILE_ATTRIBUTE_DEVICE               0x00000040 

#define FILE_ATTRIBUTE_NORMAL               0x00000080 

#define FILE_ATTRIBUTE_TEMPORARY            0x00000100 

#define FILE_ATTRIBUTE_SPARSE_FILE          0x00000200 

#define FILE_ATTRIBUTE_REPARSE_POINT        0x00000400 

#define FILE_ATTRIBUTE_COMPRESSED           0x00000800 

#define FILE_ATTRIBUTE_OFFLINE              0x00001000 


#define FILE_ATTRIBUTE_ENCRYPTED            0x00004000 

#define FILE_WRITE_ATTRIBUTES                                0x100

#define GENERIC_WRITE     (0x40000000)

#define GENERIC_READ      (0x80000000)



*From winbase.h:

#define CREATE_NEW          1

#define CREATE_ALWAYS       2

#define OPEN_EXISTING       3

#define OPEN_ALWAYS         4



PROCEDURE ReTimeStamp(cFilename as string, dt as Datetime)

                   DECLARE integer CreateFile in win32api string, integer dwDesiredAccess, integer dwShareMode, integer security, ;

                             integer dwCreationDisposition, integer FlagsAttrs, integer hTemplate

                   DECLARE INTEGER CloseHandle in win32api integer hFile

                   DECLARE integer SystemTimeToFileTime IN WIN32API string , string @

                   DECLARE INTEGER SetFileTime IN kernel32;

                             INTEGER hFile, STRING lpCreationTime,;

                             STRING lpLastAccessTime, STRING lpLastWriteTime

                   DECLARE INTEGER SystemTimeToFileTime IN kernel32;

                             STRING lpSystemTime, STRING @lpFileTime

                   DECLARE INTEGER LocalFileTimeToFileTime IN kernel32;

                             STRING lpLocalFileTime, STRING @lpFileTime

                   DECLARE integer GetLastError in win32api


                   cFileTime = SPACE(8)

                   cSysTime=BINTOC(YEAR(dt),"2rs") + ;

                                      BINTOC(MONTH(dt),"2rs") + ;

                                      BINTOC(DOW(dt,0),"2rs") + ;

                                      BINTOC(DAY(dt),"2rs") + ;

                                      BINTOC(HOUR(dt),"2rs") + ;

                                      BINTOC(MINUTE(dt),"2rs") + ;


                   SystemTimeToFileTime(cSysTime, @cFileTime)


                   LocalFileTimeToFileTime(cFileTime, @cFileTime)


                   hFile = CreateFile(cFilename, GENERIC_WRITE+GENERIC_READ,FILE_SHARE_READ, 0, OPEN_EXISTING, 0,0)

                   SetFileTime(hFile , cFileTime, cFileTime,cFileTime)





Comments (7)

  1. Tom says:

    this program is great for fixing the timestamps in the EXIF headers of JPEG files:


  2. Bryan Wetton says:

    Very Interested in your routine.

    In VFP6 compiling the routine as printed throws up errors.

    Am I doing something wrong?



  3. I was running out of space again on my notebook. As years go by, digital cameras can take pictures with

  4. I was running out of space again on my notebook. As years go by, digital cameras can take pictures with

  5. Olgunka-ta says:

    <a href= http://index3.tsopol.com >xxxalbum</a> <a href= http://index1.tsopol.com >female muslim doctor threatened with death for disputing koran teachings</a> <a href= http://index5.tsopol.com >glass telephones</a> <a href= http://index4.tsopol.com >cockroaches in apartments</a> <a href= http://index2.tsopol.com >vacume line scamatic for 1969 grand torino</a>

  6. jyner_mb says:

    <a href= http://bzquoyi.angelfire.com >arts.li</a> <a href= http://oamxiea.angelfire.com >s & e r construction buildings inc.</a> <a href= http://qemmojq.angelfire.com >premium landscape soil</a> <a href= http://wfzodej.angelfire.com >pregnetdogs</a> <a href= http://nlohdky.angelfire.com >plattsburgh new york health center address phone number</a>

  7. garry-bb says:

    <a href= http://index1.parametr-x.ru >���������� ������� ������ ����� �����</a> <a href= http://index2.parametr-x.ru >������� ����� ������� ����</a> <a href= http://index3.parametr-x.ru >�������� ��������� ������ ���������</a> <a href= http://index4.parametr-x.ru >������� ��������� �������� ����</a> <a href= http://index5.parametr-x.ru >�������� ����� �����</a>

Skip to main content