Sign in to follow this  
Followers 0
Rawox

FileGetTime not returning correct information?

4 posts in this topic

Ok, So I wrote the function displayed beneath and call it with:

ConsoleWrite ( $n & ". " & GUICtrlRead ( $Folder2 ) & "\" & $FileArray[$n] & @TAB & "===>" & @TAB & GUICtrlRead ( $Folder3 ) & "\" & _convertFileName ( $FileArray[$n], GUICtrlRead ( $Folder2 ) ) & @CRLF )

Func _convertFileName ( $FName, $FDir )
    $CurrentFile = $FDir & "\" & $FName
    _PathSplit ( $CurrentFile, $szDrive, $szDir, $szFName, $szExt )
    $Time = FileGetTime ( $CurrentFile, 1 )
    If @error = 1 Then Msgbox ( 0,0,1 )
    $NewFileName = GUICtrlRead ( $FileNames ) & $szExt
    $NewFileName = StringReplace ( $NewFileName, ":Y:", $Time[0] )
    $NewFileName = StringReplace ( $NewFileName, ":M:", $Time[1] )
    $NewFileName = StringReplace ( $NewFileName, ":D:", $Time[2] )
    $NewFileName = StringReplace ( $NewFileName, ":h:", $Time[3] )
    $NewFileName = StringReplace ( $NewFileName, ":m:", $Time[4] )
    $NewFileName = StringReplace ( $NewFileName, ":s:", $Time[5] )
    Return $NewFileName
EndFunc

For the file 'Aqua Space.jpg' which I use for testing with some other files I get this returned:

1. C:\ScriptTemp\Input1\IMG_0413.JPG    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-03-22 [12:03].JPG
2. C:\ScriptTemp\Input1\IMG_0417.JPG    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-03-22 [12:03].JPG
3. C:\ScriptTemp\Input1\Port.jpg    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-08-28 [14:08].jpg
4. C:\ScriptTemp\Input1\Serenity.jpg    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-08-28 [14:08].jpg
5. C:\ScriptTemp\Input2\1680x1050.jpg   ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-08-28 [14:08].jpg
[b]6. C:\ScriptTemp\Input2\Aqua Space.jpg   ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-08-28 [14:08].jpg[/b]
7. C:\ScriptTemp\Input2\IMG_0480.JPG    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-03-22 [12:03].JPG
8. C:\ScriptTemp\Input2\IMG_0526.JPG    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-03-22 [12:03].JPG
9. C:\ScriptTemp\Input2\IMG_0527.JPG    ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-03-22 [12:03].JPG
10. C:\ScriptTemp\Input2\Huge Metal Fan.gif ===>    C:\ScriptTemp\Output\Vakantie Kroatië 2010-08-28 [14:08].gif

Which is wierd because the information displayed by Windows (7 64Bit) is attached and is not the same.

post-40706-12830242190981_thumb.png

And I don't really need the creation date I need the date a photograph was taken on (Those can be different and I really need to get the 'taken' date )

Does anyone know why these values are not the same?

Thanks in advance, Rawox

P.S. The script moves images and changes the name to a tag and the date the picture was taken.

Translations:

Genomen op = Taken on <== I need that one
Aanmaakdatum = Created on
Gewijzigd op = Modified on

Share this post


Link to post
Share on other sites



Rawox,

To get the "date taken", try reading the file properties like this: ;)

$sFile = FileOpenDialog("Choose Photo", "Your_Path\", "Images(*.jpg)")

ConsoleWrite(_GetDate($sFile) & @CRLF)

Func _GetDate($sPassed_File_Name)

    Local $iError = 0

    Local $sDir_Name = StringRegExpReplace($sPassed_File_Name, "(^.*\\)(.*)", "\1")
    Local $sFile_Name = StringRegExpReplace($sPassed_File_Name, "^.*\\", "")

    Local $sDOS_Dir = FileGetShortName($sDir_Name, 1)

    Local $oShellApp = ObjCreate("shell.application")
    If IsObj($oShellApp) Then
        Local $oDir = $oShellApp.NameSpace($sDOS_Dir)
        If IsObj($oDir) Then
            Local $oFile = $oDir.Parsename($sFile_Name)
            If IsObj($oFile) Then

                If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
                    
                    Return $oDir.GetDetailsOf($oFile, 12) ; Date Taken
                    
                EndIf

            Else
                $iError = 3
            EndIf
        Else
            $iError = 2
        EndIf
    Else
        $iError = 1
    EndIf

    If $iError > 0 Then
        Local $sMsg = "Could not read File Properties" & @CRLF & @CRLF & _
        $iError & @CRLF & @CRLF & $sPassed_File_Name
        MsgBox(0, "Error", $sMsg)
    EndIf

EndFunc

You have some work to do on the returned value, but that should not pose a too big a problem. ;)

I hope this helps. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Why are you using FileGetTime? It only returns:

[optional] Flag to indicate which timestamp

0 = Modified (default)

1 = Created

2 = Accessed

Not EXIF.

So how to read EXIF then?

Lazycat made a UDF for that, LINK.

_GetExtProperty should also work (like Melba23 posted).

The value for WinXP (I think Win2K had the same as XP) seems to be 25 or/and 31 (same thing but different formats).

[25]|2010-08-03 17:22

[31]|2010:08:03 17:22:38

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Thank you very much, both Melba and AdmiralAlkex!

I thought the 'created date' was the same as the 'taken date' but it wasn't. With these examples I can finish my script!

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0