Go to:  Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text bottom

RENPHOT  PowerBASIC  Procedure  (32-bit)

         

RENPHOT procedure (external program executable from Windows command session) generates unique names for image files recorded by a digital camera basing on date-time stamps contained within files.

Direct dependencies:

COMPRES$ Compress character string function
CURDATE$ Form Current Date String function
CURTIME$ Form current time string function
DAY2GRE$ Convert absolute day number into Gregorian date function
DIGITAL% Check character string for digital value function (predicate)
GRE2DAY& Convert Gregorian date into absolute day number function
PARSSTR% Parse character string into substring array function
PRNTCLR Print colored text to screen routine
TRANS$ Translate character string symbols function
WEEKDAY$ Form day of a week abbreviated name function

Indirect dependencies:

LEAP% Check year for leap value function (predicate)
VALDGRE% Check date for valid Gregorian value function (predicate)

You can get more details about RENPHOT program origins, design and usage in the Download section.



 RENPHOT  Source  Program                         Debugging data                     Debugging logouts

      ' RENPHOT(7.1)  Rename Digital Photo Image JPG Files       01/18/1999-04/16/2010
      ' ------------------------------------------------------------------------------
      ' Copyright (C) 1999-2010 by Vladimir Veytsel                      www.davar.net

      ' Type -------------------------------------------------------------------------

      '    Procedure

      ' Description ------------------------------------------------------------------

      '    Program generates meaningful unique names for photo image files, deriving
      '    them from the date-time stamps contained within the files as recorded by a
      '    digital camera.  Additional information can be used to further identify and
      '    describe image files, and recorded time can be adjusted up to 12 hours in
      '    either direction.

      '    Ideally a digital camera itself should do this job, but file naming seems
      '    to be of a little concern for camera designers - still the same after 10+
      '    years since the first version of this program was originally developed.
      '    Amount of new options that have been added to digital cameras in the first
      '    decade of 21 century is virtually mind-boggling; many of them for a casual
      '    user are practically useless - IMHO.  Yet, such a basic camera function as
      '    meaningful naming of image files is still altogether ignored - to the best
      '    of my knowledge at least.

      '    Program supports two renaming modes, corresponding to two image file name
      '    formats - short and long.

      '    - Short image file names:
      '      YYYY-MM-DD_HH-MM-SS[_Tag].JPG

      '      Tag is an optional short qualifier added to file names; it's detailed
      '      description can be found below.

      '      DESCRIPT.ION file is generated with the following entries for each file:
      '      <File_Name>.jpg DoW MM/DD/YYYY HH:MM[ Tag]  Global Description
      '      Note: Date and time format shown above is the default; it can be changed
      '            by program parameters.

      '      It supports image files' viewing and manipulation by programs that make
      '      use of DESCRIPT.ION files,
      '      E.g.: ACDSee Classic

      '    - Long image file names:
      '      YYYY-MM-DD_DoW_HH-MM-SS[_Tag]_Global_Description.jpg
      '      Note: Global Description gets converted to suit file naming conventions,
      '            and all spaces are converted to "_".

      '      No DESCRIPT.ION file is generated for long file names - long names are
      '      self-sufficient.

      '    The choice between short and long names is not clear-cut, and could vary
      '    depending on taste or/and circumstance.  For one example, my preference
      '    is to use short names with DESCRIPT.IONs for my photo archives - I perceive
      '    long names as sort of being excessively bulky for a regular image handling.
      '    On the other hand, when I send photos outside, I convert their names to the
      '    long format that is self-sufficient, and thus is better suited for images
      '    that potentially could be conveniently viewed just by ANY image viewer.

      '    There is a supplemental bridge program DSC2LNG that can convert all image
      '    file names in the CURRENT directory from short names accompanied by the
      '    DESCRIPT.ION file to the long file names.  DSC2LNG creates batch script for
      '    the option of the reverse renaming (back from long to short file names).
      '    DESCRIPT.ION file gets renamed into DESCRIPT.RSV after conversion completion.
      '    Batch for reverse renaming and preserved DESCRIPT.RSV file could come handy
      '    for easy reversing of directory naming scheme.  Reversing by back conversion
      '    is impossible, since certain loss of data happens during the short to long
      '    conversion - any symbols are permitted in DESCRIPT.ION, while some are
      '    prohibited for file names.

      '    RENPHOT reads all *.JPG files within the CURRENT directory, and renames
      '    those that have a non-zero recorded date and time stamp.  Recorded date
      '    and time can be adjusted (for renaming purposes only) by a fixed value to
      '    handle the situation when pictures were taken in a time zone different
      '    from one where camera clock was set, or to correct error of camera clock.

      '    NB: No change is ever made to the file contents - this program is absolutely
      '        safe to use; it affects only names of image files, never their contents.
      '        The worst case scenario could be just incorrect (not what was intended)
      '        naming of the image files, which could be easily fixed, and is no big a
      '        loss anyway - camera recorded names are meaningless also - they reflect
      '        image taking sequence only.

      ' Control Parameters (Up to 8 Positional Self-Delimited) -----------------------

      '    1. Global description comment to be associated with every image file (might
      '       be handy as an event or/and place identification that can be individually
      '       adjusted later as necessary for selected images).

      '    2. Tag - an optional short qualifier added to file names; useful when the
      '       same event was photographed by several cameras simultaneously, and it's
      '       desirable to merge results into the same directory without causing name
      '       conflicts.  After being renamed by RENPHOT in the separate directories,
      '       tag-ed image files could then safely be merged into one directory.
      '       E.g.: "C" for pictures taken by one camera, and "N" taken by another, or
      '             more descriptive: "Canon" and "Nikon", or photographers: "Vlad"
      '             and "Vict", or just about anything fitting this purpose.

      '    3. Renaming mode indicator:
      '       L  - Long image names
      '       S  - Short image names and DESCRIPT.ION
      '       Note: IF Global description is empty
      '                THEN mode value of "S" is enforced
      '                     (Long image names don't make sense in this case);
      '                ELSE any mode value other than "L" is equivalent to "S".

      '    4. Date-time stamp delimiter recorded by the camera (Default: ":").

      '    5. Number of date-time stamp entry to select (Default: 2).  Camera usually
      '       writes several dates, and certain investigation and trial might be required
      '       to determine what date-time stamp is the most reliable (for all the cameras
      '       that I've used - from Olympus D400, through multiple Canons, and ending up
      '       with Nikon D5000 - it happened to be the 2-nd date).

      '    6. Date translation pattern for DESCRIPT.ION entries (Default: "MO/DA/CNYE")
      '       Date is recorded by the camera as "CNYE:MO:DA" (":" stands here for the
      '       camera-recorded date-time stamp delimiter), where:
      '          CN  - Current century
      '          YE  - Year  of current century
      '          MO  - Month of current year
      '          DA  - Day   of current month
      '       Pattern for the date to be written to the corresponding line of DESCRIPT.ION
      '       file can be composed of above listed date fields and any delimiters different
      '       from DAMOYECN characters, e.g.:
      '       MO/DA/CNYE  or  MO/DA/YE
      '       DA.MO.CNYE  or  DA.MO.YE
      '       CNYE-MO-DA  or  YE-MO-DA, etc.

      '    7. Time translation pattern for DESCRIPT.ION entries (Default: "HR:UT")
      '       Time is recorded by the camera as "HR:UT:SZ" (":" stands here for the
      '       camera-recorded date-time stamp delimiter), where:
      '          HR  - Hour   of current day
      '          UT  - Minute of current hour
      '          SZ  - Second of current minute
      '       Pattern for the time to be written to the corresponding line of DESCRIPT.ION
      '       file can be composed of above listed time fields and any delimiters different
      '       from HRUTSZ characters, e.g.:
      '       HR:UT:SZ  or  HR:UT
      '       HR.UT.SZ  or  HR.UT
      '       HR-UT/SZ  or  HR-UT, etc.

      '    8. Time adjustment increment/decrement (Default: none), e.g.:
      '       +08:00  or   -02:30  - Should have fixed sHR:UT format, when specified.
      '       HR<=12  and  UT<=59  - Invalid parameter (format or value) is ignored.
      '       Time adjustment comes handy in case you've been traveling, and taking
      '       pictures in another time zone, but didn't adjust the camera clock
      '       (who does?).  This might be a minor annoyance, but why not to fix it
      '       in the same run with image files' renaming?
      '       It's sufficient, of course, to have only hours for time zone adjustment;
      '       minutes are added just in case it would be desirable to correct an error
      '       of the camera clock.
      '       Be careful with the sign setting; you've got to have it "+", if pictures
      '       were taken East of the location where camera clock was set (things happen
      '       "earlier" there), and "-", if pictures were taken West.

      '    Note: In order to permit any symbols within global description comment,
      '          and to accommodate for any possible recorded date-time stamp
      '          delimiter, as well as any delimiters within date and time patterns,
      '          parameter string is treated as being self-delimited, i.e. its FIRST
      '          symbol is used as the delimiter of individual parameters.  It's up to
      '          the user to specify delimiter with the parameters, and to choose it
      '          carefully to avoid parameter misinterpretation.
      '          E.g.:
      '          RENPHOT                           - All parameters are defaulted
      '          RENPHOT _Comment, etc._Tag        - Symbol "_" is the delimiter
      '          RENPHOT /Comment, etc.//S/:       - Symbol "/" is the delimiter
      '          RENPHOT \Comment, etc.\Tag\L\:\1  - Symbol "\" is the delimiter
      '          RENPHOT !Comment, etc.!!S!:!3     - Symbol "!" is the delimiter

      '          NB: Don't use any of "<|>" symbols as delimiter!

      ' Action -----------------------------------------------------------------------

      '  - Reads date and time stamp from every *.JPG file in the CURRENT directory
      '    in the form of CNYE:MO:DA HR:UT:SZ (":" is assumed to be date delimiter).

      '  - Renames each file according to renaming mode, using data from date and
      '    time stamp within the image file recorded by the camera.

      '  - Quite rare, but technically possible case when several photos are taken
      '    in the span of the SAME second is handled by adding when it's necessary
      '    an additional qualifier right after the seconds field in the form of "~n",
      '    where "n" can take successive values: 1...9A...Z - 35 possibilities total,
      '    enough for any real-life situation.  It might be possible to use seconds
      '    value incrementing instead of this (the same way this was dome with the
      '    minutes incrementing in earlier version of this program), but it would
      '    result in complication of conversion between short and long names, which
      '    could be avoided by using qualifier instead of incrementing seconds field.

      '  - Image description record is appended to DESCRIPT.ION file.  Description
      '    record has the following format (includes Day-of-Week identification):
      '    <File_Name>.jpg DoW MM/DD/YYYY HH:MM[ Tag]  Global_Description

      '    Note:  Date and time are translated according to the default pattern
      '           in the above example.  Alternative translation patterns can be
      '           specified.

      ' Notes ------------------------------------------------------------------------

      '  - Program is designed to operate within the CURRENT directory.

      '  - Program relies on the metadata with the date-time stamp that gets written
      '    at the beginning of the *.JPG image file by a digital camera.  If date and
      '    time stamp is not found or it is all zeros, no action is taken for such file
      '    (camera should be set to write date and time to image file). To check the
      '    presence of metadata and date-time stamp view *.JPG file as a text.

      '  - Beginning of the date-time stamp is identified by the program as four
      '    successive digits starting with "19" or "20" followed by the date delimiter,
      '    E.g.:  "19yy:" or "20yy:".

      '  - Program looks for date-time stamp only within first 1000 symbols of
      '    *.JPG file.  If the number of date-time entry specified by the 3-rd
      '    parameter is not found, file is not renamed.

      '  - For proper sequencing of files in the merged directory it is essential
      '    that camera clocks are synchronized BEFORE collaborative shooting.  If
      '    this wasn't done in a due time, the necessary time adjustments could be
      '    made using RENPHOT time adjustment parameter (see description above).

      ' External Functions -----------------------------------------------------------

           #INCLUDE ONCE "COMPRES"
           #INCLUDE ONCE "CURDATE"
           #INCLUDE ONCE "CURTIME"
           #INCLUDE ONCE "DAY2GRE"
           #INCLUDE ONCE "DIGITAL"
           #INCLUDE ONCE "GRE2DAY"
           #INCLUDE ONCE "PARSSTR"
           #INCLUDE ONCE "TRANS"
           #INCLUDE ONCE "WEEKDAY"

      ' External Routine -------------------------------------------------------------

           #INCLUDE ONCE "PRNTCLR"

      ' Start Procedure --------------------------------------------------------------

           DEFINT A-Z  ' All defaulted variables are integer

           FUNCTION PBMAIN

      ' Constant ---------------------------------------------------------------------

           Q$=CHR$(34)  ' Quotation mark

      ' Working Variable -------------------------------------------------------------

           DIM Parameter$(8)

      ' Get Control Parameters -------------------------------------------------------

           Parm$=COMMAND$
      '    Parm$=""
      '    Parm$="//Tag0"
      '    Parm$="_Comment 1. etc."
      '    Parm$="/Comment 2. etc./Tag2/L/:"
      '    Parm$="\Comment 3, etc.\Tag3\\:\1"
      '    Parm$="!Comment 4, etc.!!l!:!3"
      '    Parm$="+Comment 5: etc.+++:+3+CNYE-MO-DA"
      '    Parm$="-Comment 6: etc.--X-:-3-DA.MO.CNYE-HR.UT.SZ"
      '    Parm$="/Comment 7; etc./Tag7/Z/////+10:10"
      '    Parm$="/Comment 8; etc./Tag8/L/////-01:01"

           I=PARSSTR%(Parm$,Parameter$(),"*")

      ' Form Parameters' Actual Values -----------------------------------------------

           Descr$      =Parameter$(1)
           Tag$        =Parameter$(2)
           Mode$=UCASE$(Parameter$(3))
           Delim$      =Parameter$(4)
           IF  (DIGITAL(Parameter$(5),"")) THEN Entry=VAL(Parameter$(5))
           Date_Pat$   =Parameter$(6)
           Time_Pat$   =Parameter$(7)
           Time_Adj$   =Parameter$(8)

      ' Display Renaming Log Title and Control Parameters ----------------------------

           PRNTCLR("%W%RENPHOT(7.1)  Rename Digital Photo Image JPG Files  "+CURDATE$("CNYE-MO-DA")+"  "+CURTIME$("")+"%P%",1)
           PRNTCLR("%W%"+STRING$(69,"-")+"%P%",1)

           PRINT "Specified control parameters: ";Q$;Parm$;Q$

      ' Adjust Control Parameters ----------------------------------------------------

           IF (LEN(Descr$)=0) THEN
              Mode$="S"
           ELSE
              IF (Mode$<>"L") THEN Mode$="S"
           END IF

           IF ((Mode$="L")AND _
               (LEN(Descr$)>0)) THEN
              Descr$="_"+TRANS$(TRIM$(COMPRES$(TRANS$(Descr$,".,:;","    ")," "))," ","_")
           END IF
           IF (Delim$="")  THEN Delim$=":" :Delim$=LEFT$(Delim$,1)
           IF (Entry =0 )  THEN Entry =2

           Img_Dt_Tm_Pat$="CNYE"+Delim$+"MO"+Delim$+"DA HR"+Delim$+"UT"+Delim$+"SZ"

           IF (Date_Pat$="") THEN Date_Pat$="MO/DA/CNYE"
           IF (Time_Pat$="") THEN Time_Pat$="HR:UT"

           IF (LEN(Time_Adj$)>0) THEN
              Sign_Adj$=LEFT$(Time_Adj$,1)
              IF ((LEN(Time_Adj$)=6)        AND _  ' ----+-
                  (VERIFY(Sign_Adj$,"-+")=0)AND _  ' +12:34
                  (MID$(Time_Adj$,4,1)=":") AND _
                  (DIGITAL(MID$(Time_Adj$,2,2)+RIGHT$(Time_Adj$,2),""))) THEN
                 Hours_Adj  =VAL(  MID$(Time_Adj$,2,2))
                 Minutes_Adj=VAL(RIGHT$(Time_Adj$,2))
                 IF ((Hours_Adj<=12)AND _
                     (Minutes_Adj<=59)) THEN
                    Minutes_Incr=Hours_Adj*60+Minutes_Adj
                    IF (Sign_Adj$="-") THEN
                       Minutes_Incr=Minutes_Incr*(-1)
                    END IF
                    CALL PRNTCLR("%R%Note: Time of each picture will be adjusted by the value of %C%"+Q$+Time_Adj$+Q$+"%R%",1)
                 ELSE
                    CALL PRNTCLR("%R%Invalid time adjustment parameter value[s]: "+Q$+Time_Adj$+Q$+"  %R%- Ignored%P%",1)
                 END IF
              ELSE
                 CALL PRNTCLR("%R%Invalid time adjustment parameter format: "+Q$+Time_Adj$+Q$+"  %R%- Ignored%P%",1)
              END IF
           END IF

      ' Display Actual Control Parameters --------------------------------------------

           PRINT "Actual control parameters:"
           PRINT "   Description  . : ";Q$;Descr$;Q$
           PRINT "   Tag  . . . . . : ";Q$;Tag$;Q$
           PRINT "   Mode . . . . . : ";Q$;Mode$;Q$
           PRINT "   Delimiter  . . : ";Q$;Delim$;Q$
           PRINT "   Entry  . . . . : ";Entry
           IF (Mode$="S") THEN
              PRINT "   Date_Pattern . : ";Q$;Date_Pat$;Q$
              PRINT "   Time_Pattern . : ";Q$;Time_Pat$
           END IF
           PRINT "   Time_Adjustment: ";Q$;Time_Adj$;Q$

      ' Open Directory Description File ----------------------------------------------

           IF (Mode$="S") THEN OPEN "DESCRIPT.ION" FOR OUTPUT AS #1

      ' Process All Files in Current Directory ---------------------------------------

           ON ERROR RESUME NEXT      ' Bypass system action on file renaming error

           File_Name$=DIR$("*.JPG")  ' Get first file name

           DO UNTIL (File_Name$="")
              GOSUB Process_File
              File_Name$=DIR$        ' Get next file name
           LOOP

      ' Finish Processing ------------------------------------------------------------

           CLOSE
           GOTO Finish_Procedure

      Process_File:  ' Routine -------------------------------------------------------

           GOSUB Get_Date_Time

           IF (Mode$="S") THEN
              File_Descr$=WEEKDAY(TRANS$("MO-DA-CNYE",Img_Dt_Tm_Pat$,Image_Date_Time$))+" "+ _
                                  TRANS$(Date_Pat$   ,Img_Dt_Tm_Pat$,Image_Date_Time$) +" "+ _
                                  TRANS$(Time_Pat$   ,Img_Dt_Tm_Pat$,Image_Date_Time$)+"  "+ _
                                  Descr$
           END IF

           IF (No_Date) THEN
              PRNTCLR("%M%"+Image_Date_Time$+ "  %R%"+File_Name$+" %M%--- %R%Renaming is impossible!%P%",1)
           ELSE
              GOSUB Form_New_Name
              IF (File_Name$<>New_Name$) THEN
                 GOSUB Rename_File
                 IF (Mode$="S") THEN PRINT #1,New_Name$;" ";File_Descr$
              END IF
           END IF

           RETURN  ' From Process_File routine

      Get_Date_Time:  ' Routine ------------------------------------------------------

           OPEN File_Name$ FOR BINARY AS #2

           I&=1
           FOR J=1 TO Entry
               Year$="****"
               FOR I&=I& TO 1000    ' Find the nearest date delimiter
                   GET$ #2,1,Symb$  ' which follows 4 digits (19yy or 20yy)
                   Year$=RIGHT$(Year$+Symb$,5)
                   IF ((Symb$=Delim$)         AND _
                       (DIGITAL(Year$,Delim$))AND _
                       (( LEFT$(Year$,2)="19")OR  _
                        ( LEFT$(Year$,2)="20"))) THEN
                      EXIT
                   END IF
               NEXT I&
               IF (J<>Entry) THEN
                  I&=I&+15
                  SEEK #2,I&  ' Skip date and time stamp
               END IF
           NEXT J

           SEEK #2,I&-4
           GET$ #2,19,Image_Date_Time$

           CLOSE #2

           IF (DIGITAL(LEFT$(Image_Date_Time$,4),"")) THEN
              No_Date=0
           ELSE
              No_Date=-1
              Image_Date_Time$="No date in image!!!"
           END IF

           IF (NOT(No_Date)) THEN  ' Adjust time for existing date only
      '       ----+----1----+----  Time adjustment is below
      '       2002:04:21 10:10:36  Image_Date_Time$ format example
              File_Date_Time$=Image_Date_Time$  ' Save for displaying in renaming log
              IF (Minutes_Incr<>0) THEN
                 Minutes_Abs&=GRE2DAY&(MID$(Image_Date_Time$, 6,5)+":"   + _
                                      LEFT$(Image_Date_Time$,   4))*24*60+ _
                                   VAL(MID$(Image_Date_Time$,12,2))   *60+ _
                                   VAL(MID$(Image_Date_Time$,15,2))
                 Minutes_Abs&=Minutes_Abs&+Minutes_Incr
                 Hours_Abs&=INT(Minutes_Abs&/60)
                 MID$(Image_Date_Time$,15,2)=RIGHT$("0"+LTRIM$(STR$(Minutes_Abs& MOD 60)),2)
                 Days_Abs&=INT(Hours_Abs&/24)
                  MID$(Image_Date_Time$,12,2)=RIGHT$("0"+LTRIM$(STR$(Hours_Abs& MOD 24)),2)
                 Adjusted_Date$=DAY2GRE$(Days_Abs&)
                 MID$(Image_Date_Time$,1,10)=RIGHT$(Adjusted_Date$,4)+":"+LEFT$(Adjusted_Date$,5)
                 MID$(Image_Date_Time$,8,1)=":"  ' Adjust delimiter
              END IF
           END IF

           RETURN  ' From Get_Date_Time routine

      Form_New_Name:  ' Routine ------------------------------------------------------

           IF (Mode$="S") THEN
              New_Name$=TRANS$("CNYE-MO-DA_HR-UT-SZ",Img_Dt_Tm_Pat$,Image_Date_Time$)+ _
                        IIF$(Tag$<>"","_"+Tag$,"")+".JPG"
           ELSE
              New_Name$=TRANS$("CNYE-MO-DA_",Img_Dt_Tm_Pat$,Image_Date_Time$) + _
                WEEKDAY(TRANS$("MO-DA-CNYE" ,Img_Dt_Tm_Pat$,Image_Date_Time$))+ _
                        TRANS$("_HR-UT-SZ"  ,Img_Dt_Tm_Pat$,Image_Date_Time$) + _
                        IIF$(Tag$<>"","_"+Tag$,"")+Descr$+".jpg"
           END IF

           RETURN  ' From Form_New_Name routine

      Rename_File:  ' Routine --------------------------------------------------------

           Renamed=0
           I=0
           J=4*(Mode$="L")
           DO UNTIL (Renamed)
              NAME File_Name$ AS New_Name$
              IF (ERRCLEAR=58) THEN  ' New_Name$ already exists
                 I=I+1
                 IF (I=1) THEN
                    New_Name$=LEFT$(New_Name$,19-J)+"~1"+MID$(New_Name$,20-J)
                 ELSE
                    New_Name$=LEFT$(New_Name$,20-J)                           _
                             +MID$("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",I,1) _
                             +MID$(New_Name$,22-J)
                 END IF
              ELSE
                 IF (Mode$="S") THEN
                    PRNTCLR("%C%"+File_Date_Time$+"  %P%"+File_Name$+" %G%--> %W%"+New_Name$+"  %P%"+File_Descr$,1)
                 ELSE
                    PRNTCLR("%C%"+File_Date_Time$+"  %P%"+File_Name$+" %G%--> %W%"+New_Name$+"%P%",1)
                 END IF
                 Renamed=-1
              END IF
           LOOP

           RETURN  ' From Rename_File routine

      Finish_Procedure:  ' -----------------------------------------------------------

           END FUNCTION
  
         

 RENPHOT  Debugging  Data                         Source program                   Debugging logouts

         

Three photo JPG files from three different digital cameras were used for RENPHOT debugging.  Headers of these files (browsed by ZTreeWin) are presented below.  (There are also two files to show error messages: one

There are also two files to show error messages: one with no date at all (removed during PhotoShop processing), and another with all zero dates (once in a while camera could loose its date setting).

Note:  Debugging files were slightly modified to facilitate debugging of the date occurrence selection logic.  In real life some of the occurrences might be all zeros for whatever reason.  All occurrences that are non-zero are always identical (to the best of my knowledge, of course).  To distinguish between date occurrences during debugging I've incremented minutes by "1" in the second date-time occurrence and by "2" in the third.  This doesn't effect in any way the renaming logic, but permits to tell during debugging exactly what date-time occurrence has been chosen by the program.


          C:\DEBUG\OLYMP400.JPG Olympus D400 photo JPG file head.

         

  C:\DEBUG\OLYMP400.JPG
 
  00000000  ......Exif..II*........... .....................................
  00000040  ..............................(...........1...........2.........
  00000080  ..............i...............OLYMPUS DIGITAL CAMERA         .OL
  000000C0  YMPUS OPTICAL CO.,LTD.C900Z,D400Z...H.......H.......v872-72.....
  00000100  ....................1999:04:12 14:41:37...........*...........2.
  00000140  ..'.......d...........0210........:...........N.................
  00000180  ......b...........j...........r.................................
  000001C0  ..............z...|.......|.......}...............0100..........
  00000200  ..................................^.......................*...#.
  00000240  ......1999:04:12 14:42:37.1999:04:12 14:43:37...................
  00000280  ......P...............
  000002C0
  00000300             .......................N...........V...(.............
  00000340  ..........................H.......H.................R98.........
  00000380  0100....OLYMP...................................................
  000003C0  ......................"...........*...........6.......4...>.....
  00000400  .. ...z...........................................d.............
  00000440  ..SR872...[pictureInfo] Resolution=2 [Camera Info] Type=SR872...
  00000480  ......OLYMPUS DIGITAL CAMERA................O.........\"......\"
      
         
C:\DEBUG\OLYMP510.JPG Olympus D510 photo JPG file head.

         

  C:\DEBUG\OLYMP510.JPG
 
  00000000  ....8EExif..II*........... .....................................
  00000040  ..............................(...........1...........2.........
  00000080  ..............i...............OLYMPUS DIGITAL CAMERA         .OL
  000000C0  YMPUS OPTICAL CO.,LTD.C200Z,D510Z...H.......H.......v358u-76....
  00000100  ....................2002:02:06 20:10:29...........B...........J.
  00000140  .."...........'...................0210........R...........f.....
  00000180  ..................z.............................................
  000001C0  ..............................|...............}...............01
  00000200  00............................................v.................
  00000240  ......................#.......2002:02:06 20:11:29.2002:02:06 20:
  00000280  12:29.................$.......P...............
  000002C0
  00000300                                     .......................f.....
  00000340  ......n...(.......................................H.......H.....
  00000380  ............R98.........0100....OLYMP.............b.............
  000003C0  ..................................n...........v...........~.....
  00000400  ..............4........... .....................................
  00000440  ..........................................................d...d.
  00000480  ......d...............SX358...[pictureInfo] Resolution=1 [Camera
      
         
C:\DEBUG\SONYCBSH.JPG Sony CyberShot photo JPG file head.

         

  C:\DEBUG\SONYCBSH.JPG
 
  00000000  .....3Exif..II*........... .....................................
  00000040  ..............................(...........2.....................
  00000080  ..i...........d...                               .SONY..CYBERSHO
  000000C0  T.......H.......H.......2001:11:16 11:35:00.....................
  00000100  ......"...........'.......d...........0210......................
  00000140  ......................&.......................6.................
  00000180  ..............................>...........0100..................
  000001C0  ..........................F...................................-.
  00000200  ..........2001:11:16 11:36:00.2001:11:16 11:37:00...............
  00000240  ..........G.................R98.........0100....................
  00000280  ..........................................................(.....
  000002C0  ......2.......................................SONY..CYBERSHOT...
  00000300  ....H.......H.......2001:11:16 11:35:00........................(
  00000340  .....1#%.(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egc......./../cB8Bc
  00000380  ccccccccccccccccccccccccccccccccccccccccccccccccc...............
  000003C0  ..................................}........!1A..Qa."q.2....#B...
  00000400  R..$3br........%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz....
  00000440  ................................................................
  00000480  ..................................................w.......!1..AQ
      
         

Three debugging files OLYMP400.JPG, OLYMP510.JPG, and SONYSBSH.JPG were copied from C:\DEBUG directory to C:\PBASIC (current directory for program debugging) for each debugging test case determined as the commented out line in the set of control parameters (see commented out lines in Get Control Parameters) that were used during initial program debugging in PBCC IDE.  Two invalid date files NO-DATE.JPG and ZERODATE.JPG were permanently present in C:\PBASIC — they never get renamed.

Verification was performed from Windows CMD session with C:\PBASIC directory as current by running RENPHOT with corresponding set of parameters. Results were analyzed and renamed JPG files along with DESCRIPT.ION were deleted from C:\PBASIC directory in preparation for the next test.


         

 RENPHOT  Debugging  Logouts                       Source program                   Debugging data
         

For each test case below (defined in program text by commented Parm$ line) corresponding renaming logout is shown along with generated DESCRIPT.ION file.

         

   Parm$=""
        
      
         

   C:\PBASIC>RENPHOT
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  13:50
   ---------------------------------------------------------------------
   Specified control parameters: ""
   Actual control parameters:
      Description  . : ""
      Tag  . . . . . : ""
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-12_14-42-37.JPG  Mon 04/12/1999 14:42
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-06_20-11-29.JPG  Wed 02/06/2002 20:11
   2001:11:16 11:36:00  SONYSBSH.JPG --> 2001-11-16_11-36-00.JPG  Fri 11/16/2001 11:36
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-42-37.JPG Mon 04/12/1999 14:42
   2002-02-06_20-11-29.JPG Wed 02/06/2002 20:11
   2001-11-16_11-36-00.JPG Fri 11/16/2001 11:36
      
         

   Parm$="//Tag0"
        
      
         

   C:\PBASIC>RENPHOT //Tag0
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  14:08
   ---------------------------------------------------------------------
   Specified control parameters: "//Tag0"
   Actual control parameters:
      Description  . : ""
      Tag  . . . . . : "Tag0"
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-12_14-42-37_Tag0.JPG  Mon 04/12/1999 14:42
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-06_20-11-29_Tag0.JPG  Wed 02/06/2002 20:11
   2001:11:16 11:36:00  SONYSBSH.JPG --> 2001-11-16_11-36-00_Tag0.JPG  Fri 11/16/2001 11:36
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-42-37_Tag0.JPG Mon 04/12/1999 14:42
   2002-02-06_20-11-29_Tag0.JPG Wed 02/06/2002 20:11
   2001-11-16_11-36-00_Tag0.JPG Fri 11/16/2001 11:36
      
         

   Parm$="_Comment 1. etc."
        
      
         

   C:\PBASIC>RENPHOT _Comment 1. etc.
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  21:27
   ---------------------------------------------------------------------
   Specified control parameters: "_Comment 1. etc."
   Actual control parameters:
      Description  . : "Comment 1. etc."
      Tag  . . . . . : ""
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-12_14-42-37.JPG  Mon 04/12/1999 14:42  Comment 1. etc.
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-06_20-11-29.JPG  Wed 02/06/2002 20:11  Comment 1. etc.
   2001:11:16 11:36:00  SONYSBSH.JPG --> 2001-11-16_11-36-00.JPG  Fri 11/16/2001 11:36  Comment 1. etc.
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-42-37.JPG Mon 04/12/1999 14:42  Comment 1. etc.
   2002-02-06_20-11-29.JPG Wed 02/06/2002 20:11  Comment 1. etc.
   2001-11-16_11-36-00.JPG Fri 11/16/2001 11:36  Comment 1. etc.
      
         

   Parm$="/Comment 2. etc./Tag2/L/:"
        
      
         

   C:\PBASIC>RENPHOT /Comment 2. etc./Tag2/L/:
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  22:14
   ---------------------------------------------------------------------
   Specified control parameters: "/Comment 2. etc./Tag2/L/:"
   Actual control parameters:
      Description  . : "_Comment_2_etc"
      Tag  . . . . . : "Tag2"
      Mode . . . . . : "L"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-12_Mon_14-42-37_Tag2_Comment_2_etc.jpg
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-06_Wed_20-11-29_Tag2_Comment_2_etc.jpg
   2001:11:16 11:36:00  SONYSBSH.JPG --> 2001-11-16_Fri_11-36-00_Tag2_Comment_2_etc.jpg
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
          No DESCRIPT.ION file is generated for Mode=L – Long file names are self-sufficient.
         

   Parm$="\Comment 3, etc.\Tag3\\:\1"
        
      
         

   C:\PBASIC>RENPHOT \Comment 3, etc.\Tag3\\:\1
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  22:36
   ---------------------------------------------------------------------
   Specified control parameters: "\Comment 3, etc.\Tag3\\:\1"
   Actual control parameters:
      Description  . : "Comment 3, etc."
      Tag  . . . . . : "Tag3"
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  1
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:41:37  OLYMP400.JPG --> 1999-04-12_14-41-37_Tag3.JPG  Mon 04/12/1999 14:41  Comment 3, etc.
   2002:02:06 20:10:29  OLYMP510.JPG --> 2002-02-06_20-10-29_Tag3.JPG  Wed 02/06/2002 20:10  Comment 3, etc.
   2001:11:16 11:35:00  SONYSBSH.JPG --> 2001-11-16_11-35-00_Tag3.JPG  Fri 11/16/2001 11:35  Comment 3, etc.
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-41-37_Tag3.JPG Mon 04/12/1999 14:41  Comment 3, etc.
   2002-02-06_20-10-29_Tag3.JPG Wed 02/06/2002 20:10  Comment 3, etc.
   2001-11-16_11-35-00_Tag3.JPG Fri 11/16/2001 11:35  Comment 3, etc.
      
         

   Parm$="!Comment 4, etc.!!l!:!3"
        
      
         

   C:\PBASIC>RENPHOT !Comment 4, etc.!!l!:!3
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-05  23:10
   ---------------------------------------------------------------------
   Specified control parameters: "!Comment 4, etc.!!l!:!3"
   Actual control parameters:
      Description  . : "_Comment_4_etc"
      Tag  . . . . . : ""
      Mode . . . . . : "L"
      Delimiter  . . : ":"
      Entry  . . . . :  3
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:43:37  OLYMP400.JPG --> 1999-04-12_Mon_14-43-37_Comment_4_etc.jpg
   2002:02:06 20:12:29  OLYMP510.JPG --> 2002-02-06_Wed_20-12-29_Comment_4_etc.jpg
   2001:11:16 11:37:00  SONYSBSH.JPG --> 2001-11-16_Fri_11-37-00_Comment_4_etc.jpg
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
          No DESCRIPT.ION file is generated for Mode=L – Long file names are self-sufficient.
         

   Parm$="+Comment 5: etc.+++:+3+CNYE-MO-DA"
        
      
         

   C:\PBASIC>RENPHOT +Comment 5: etc.+++:+3+CNYE-MO-DA
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-06  13:50
   ---------------------------------------------------------------------
   Specified control parameters: "+Comment 5: etc.+++:+3+CNYE-MO-DA"
   Actual control parameters:
      Description  . : "Comment 5: etc."
      Tag  . . . . . : ""
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  3
      Date_Pattern . : "CNYE-MO-DA"
      Time_Pattern . : "HR:UT"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:43:37  OLYMP400.JPG --> 1999-04-12_14-43-37.JPG  Mon 1999-04-12 14:43  Comment 5: etc.
   2002:02:06 20:12:29  OLYMP510.JPG --> 2002-02-06_20-12-29.JPG  Wed 2002-02-06 20:12  Comment 5: etc.
   2001:11:16 11:37:00  SONYSBSH.JPG --> 2001-11-16_11-37-00.JPG  Fri 2001-11-16 11:37  Comment 5: etc.
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-43-37.JPG Mon 1999-04-12 14:43  Comment 5: etc.
   2002-02-06_20-12-29.JPG Wed 2002-02-06 20:12  Comment 5: etc.
   2001-11-16_11-37-00.JPG Fri 2001-11-16 11:37  Comment 5: etc.
      
         

   Parm$="-Comment 6: etc.--X-:-3-DA.MO.CNYE-HR.UT.SZ"
        
      
         

   C:\PBASIC>RENPHOT -Comment 6: etc.--X-:-3-DA.MO.CNYE-HR.UT.SZ
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-06  14:39
   ---------------------------------------------------------------------
   Specified control parameters: "-Comment 6: etc.--X-:-3-DA.MO.CNYE-HR.UT.SZ"
   Actual control parameters:
      Description  . : "Comment 6: etc."
      Tag  . . . . . : ""
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  3
      Date_Pattern . : "DA.MO.CNYE"
      Time_Pattern . : "HR.UT.SZ"
      Time_Adjustment: ""
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:43:37  OLYMP400.JPG --> 1999-04-12_14-43-37.JPG  Mon 12.04.1999 14.43.37  Comment 6: etc.
   2002:02:06 20:12:29  OLYMP510.JPG --> 2002-02-06_20-12-29.JPG  Wed 06.02.2002 20.12.29  Comment 6: etc.
   2001:11:16 11:37:00  SONYSBSH.JPG --> 2001-11-16_11-37-00.JPG  Fri 16.11.2001 11.37.00  Comment 6: etc.
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-12_14-43-37.JPG Mon 12.04.1999 14.43.37  Comment 6: etc.
   2002-02-06_20-12-29.JPG Wed 06.02.2002 20.12.29  Comment 6: etc.
   2001-11-16_11-37-00.JPG Fri 16.11.2001 11.37.00  Comment 6: etc.
      
         

   Parm$="/Comment 7; etc./Tag7/Z/////+10:10"
        
      
         

   C:\PBASIC>RENPHOT /Comment 7; etc./Tag7/Z/////+10:10
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-06  18:56
   ---------------------------------------------------------------------
   Specified control parameters: "/Comment 7; etc./Tag7/Z/////+10:10"
   Note: Time of each picture will be adjusted by the value of "+10:10"
   Actual control parameters:
      Description  . : "Comment 7; etc."
      Tag  . . . . . : "Tag7"
      Mode . . . . . : "S"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT
      Time_Adjustment: "+10:10"
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-13_00-52-37_Tag7.JPG  Tue 04/13/1999 00:52  Comment 7; etc.
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-07_06-21-29_Tag7.JPG  Thu 02/07/2002 06:21  Comment 7; etc.
   2001:11:16 11:35:00  SONYSBSH.JPG --> 2001-11-16_21-46-00_Tag7.JPG  Fri 11/16/2001 21:46  Comment 7; etc.
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
         

    C:\PBASIC\DESCRIPT.ION
   
   1999-04-13_00-52-37_Tag7.JPG Tue 04/13/1999 00:52  Comment 7; etc.
   2002-02-07_06-21-29_Tag7.JPG Thu 02/07/2002 06:21  Comment 7; etc.
   2001-11-16_21-46-00_Tag7.JPG Fri 11/16/2001 21:46  Comment 7; etc.
      
         

   Parm$="/Comment 8; etc./Tag8/L/////-01:01"
        
      
         

   C:\PBASIC>RENPHOT /Comment 8; etc./Tag8/L/////-01:01
   RENPHOT(7.1)  Rename Digital Photo Image JPG Files  2016-09-06  19:36
   ---------------------------------------------------------------------
   Specified control parameters: "/Comment 8; etc./Tag8/L/////-01:01"
   Note: Time of each picture will be adjusted by the value of "-01:01"
   Actual control parameters:
      Description  . : "_Comment_8_etc"
      Tag  . . . . . : "Tag8"
      Mode . . . . . : "L"
      Delimiter  . . : ":"
      Entry  . . . . :  2
      Date_Pattern . : "MO/DA/CNYE"
      Time_Pattern . : "HR:UT
      Time_Adjustment: "-01:01"
   No date in image!!!  NO-DATE.JPG --- Renaming is impossible!
   1999:04:12 14:42:37  OLYMP400.JPG --> 1999-04-12_Mon_13-41-37_Tag8_Comment_8_etc.jpg
   2002:02:06 20:11:29  OLYMP510.JPG --> 2002-02-06_Wed_19-10-29_Tag8_Comment_8_etc.jpg
   2001:11:16 11:35:00  SONYSBSH.JPG --> 2001-11-16_Fri_10-35-00_Tag8_Comment_8_etc.jpg
   No date in image!!!  ZERODATE.JPG --- Renaming is impossible!
      
          No DESCRIPT.ION file is generated for Mode=L – Long file names are self-sufficient.
         

View [and save] RENPHOT.BAS text       Download RENPHOT.EXE file
(Use [Back] button or [Alt]+[CL] to return here from the viewed text)
To make RENPHOT.BAS source text compilable
change globally of "&lt;" into "<" signs, then "&amp;" into "&" signs.
Copyright © 19992010 by
Go to:  Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top