Jump to content

Manage pics using Exif


Recommended Posts

Hello People,

I made a program based on 6 different programs.

5 use Exif to manage all sort of medias, like jpg, gif, mov, etc.

The 6st is used to shot the screen and make a picture fil in JPG format.

For one of my pics manager, there is a problem : i can't get the width and height of a picture. So simple, no ? I spent lot of times around those programs, and now, i'm blocked with this little fu... thing :P

I would have preferred to post an entire and beautiful prog but, anyway, i can't go through and i'm angry about it.

The Function called is "SizeSorter", based on an include of "image_get_info.au3" (thanks for all this work that helped me so much).

If i change the "_IntR" call in this marvellous image_get_info, i get the good width of the pic. _IntR convert the pixel width in integer data, and i just want to use the data in pixel.

My function work on pixel data to calculate a if the multiplication of width and height are less than a level (example : 500 x 500 = 250.000). In this case, all pics result calculation under this value are moved to a folder like size folder.

Do someone have any idea to help me ? :P

Don't pay attention to ";" testing sections...

See the code below (and you can get it to ameliorate and use for yourself)

#Include <date.au3>
#include <file.au3>
#Include <GUIconstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include "image_get_info.au3"
#include <ScreenCapture.au3>

If FileExists("ExifManager.ini") Then
;do nothing
Else
    Call("ExifManagerIniCreator.exe")
EndIf

;Variables Declaration
$Font = IniRead("ExifManager.ini", "Font", "key", "NotFound")
$Program_Folder = IniRead("ExifManager.ini", "Program_Folder", "key", "NotFound")
$Default_Folder = IniRead("ExifManager.ini", "Default_Folder", "key", "NotFound")
$Folder_Exif = IniRead("ExifManager.ini", "Folder_Exif", "key", "NotFound")
$Folder_NoExif = IniRead("ExifManager.ini", "Folder_NoExif", "key", "NotFound")
$Folder_ToSort = IniRead("ExifManager.ini", "Folder_ToSort", "key", "NotFound")
$Shoots_Folder = IniRead("ExifManager.ini", "Shoots_Folder", "key", "NotFound")
$Extension_Nb = IniRead("ExifManager.ini", "Extension_Nb", "key", "NotFound")

$Prog_1 = IniRead("ExifManager.ini", "Prog_1", "key", "NotFound")
$Prog_2 = IniRead("ExifManager.ini", "Prog_2", "key", "NotFound")
$Prog_3 = IniRead("ExifManager.ini", "Prog_3", "key", "NotFound")
$Prog_4 = IniRead("ExifManager.ini", "Prog_4", "key", "NotFound")
$Prog_5 = IniRead("ExifManager.ini", "Prog_5", "key", "NotFound")

$TextButton_Prog_1 = IniRead("ExifManager.ini", "TextButton_Prog_1", "key", "NotFound")
$TextButton_Prog_2 = IniRead("ExifManager.ini", "TextButton_Prog_2", "key", "NotFound")
$TextButton_Prog_3 = IniRead("ExifManager.ini", "TextButton_Prog_3", "key", "NotFound")
$TextButton_Prog_4 = IniRead("ExifManager.ini", "TextButton_Prog_4", "key", "NotFound")
$TextButton_Prog_5 = IniRead("ExifManager.ini", "TextButton_Prog_5", "key", "NotFound")
$TextButton_Verify = IniRead("ExifManager.ini", "TextButton_Verify", "key", "NotFound")

;GUI Creation of the work window
GUICreate("ExifManager - " & @MDAY & "/" & @MON & "/" & @YEAR & " at " & @HOUR & ":" & @MIN , 300, 510)
GUISetState (@SW_SHOW)
GUICtrlCreateGroup ("Direct launch", 10, 10, 280, 280)
GUICtrlSetFont(-1, 12, 600, $Font)
GUICtrlSetColor(-1,0x008000)
GUICtrlCreateLabel($Default_Folder,  20, 40, 260)
GUICtrlSetFont(-1, 8, 400, $Font)
$Button_1 = GUICtrlCreateButton($TextButton_Prog_1, 20, 80, 260)
$Button_2 = GUICtrlCreateButton($TextButton_Prog_2, 20, 120, 260)
$Button_3 = GUICtrlCreateButton($TextButton_Prog_3, 20, 160, 260)
$Button_4 = GUICtrlCreateButton($TextButton_Prog_4, 20, 200, 260)
$Button_5 = GUICtrlCreateButton($TextButton_Prog_5, 20, 240, 260)
GUICtrlCreateGroup ("", 10, 300, 280, 50)
$CheckBoxButton = GUICtrlCreateCheckbox("Choose the folder",  20, 320, 200, 20)
GUICtrlSetFont(-1, 12, 600, $Font)
GUICtrlSetColor(-1,0xFF0000)
GUICtrlCreateGroup ("Verify", 10, 360, 280, 60)
$Button_Verif = GUICtrlCreateButton($TextButton_Verify, 20, 380, 260)
GUICtrlSetColor(-1,0x0000FF)
GUICtrlCreateGroup ("Screen Capture", 10, 440, 280, 60)
$Button_Shoot = GUICtrlCreateButton("Shoot It Now", 20, 460, 260)
GUICtrlSetColor(-1,0xFF0000)

GUISetState()
While 1
    $Msg = GUIGetMsg()
        Select
            Case $Msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $Msg = $Button_1
                If BitAnd(GUICtrlRead($CheckBoxButton),$GUI_UNCHECKED) Then
                    Call("ExifSorter")
                Else
                    Run($Prog_1)
                EndIf
            Case $Msg = $Button_2
                If BitAnd(GUICtrlRead($CheckBoxButton),$GUI_UNCHECKED) Then         
                    Call("DupliCatKiller")
                Else
                    Run($Prog_2)
                EndIf
            Case $Msg = $Button_3
                If BitAnd(GUICtrlRead($CheckBoxButton),$GUI_UNCHECKED) Then         
                    Call("CopyRightSorter")
                Else
                    Run($Prog_3)
                EndIf
            Case $Msg = $Button_4
                If BitAnd(GUICtrlRead($CheckBoxButton),$GUI_UNCHECKED) Then         
                    Call("SizeSorter")              
                Else
                    Run($Prog_4)
                EndIf
            Case $Msg = $Button_5
                If BitAnd(GUICtrlRead($CheckBoxButton),$GUI_UNCHECKED) Then         
                    Call("YearMonthSorter")
                Else
                    run($Prog_5)
                EndIf
            Case $Msg = $Button_verif
                Call("VerifReps")
            Case $Msg = $Button_Shoot
                Call("CapturIt")
        EndSelect
WEnd

;Functions to call
Func ExifSorter()
$ExifSorter_Log = IniRead("ExifManager.ini", "ExifSorter_Log", "key", "NotFound")
$Duplicated_Deep = IniRead("ExifManager.ini", "Duplicated_Deep", "key", "NotFound")
$Begin_Time = TimerInit()
TrayTip("'ExifSorter'", "Launched at " & _NowTime(), 20, 1)
$Log = FileOpen($Program_Folder & "\" & $ExifSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "ExifSorter Launch : ")
FileWrite($Log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)
FileWrite($Log, "==============================================================================" & @CRLF)
FileClose($Log)

For $i=1 to $Extension_Nb
    $LookFor = IniRead("ExifManager.ini", "Extension_" & $i, "Key", "NotFound")
    $Search = FileFindFirstFile($Default_Folder & "\" & "*." & $LookFor)
    If $Search = -1 Then
        $Log = FileOpen($Program_Folder & "\" & $ExifSorter_Log, 1)
        FileWrite($Log, @CRLF & "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
        FileWrite($Log, "No File '" & $LookFor & "' found in " & $Default_Folder & @CRLF)
        FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF & @CRLF)
        FileClose($Log)
    Else
        $Log = FileOpen($Program_Folder & "\" & $ExifSorter_Log, 1)
        While 1
            $File = FileFindNextFile($Search)
            If @error Then ExitLoop
            If Not @error Then
                $aInfo = _ImageGetInfo($Default_Folder & "\" & $File)
                $FileDate = _ImageGetParam($aInfo, "DateTimeOriginal")
                $ReplaceIt = StringReplace($FileDate, ":", "")
                $Final = StringReplace($ReplaceIt, " ", "")
                $t = FileGetTime($Default_Folder & "\" & $File, 1)
            EndIf
            If $Final > 0 Then 
                FileWrite($Log, " " & $File & " --->>> " & $Final & "." & $LookFor & " -> " & $Folder_Exif & "\" & @CRLF)
                If FileExists($Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor) Then
                    If FileExists($Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor) Then
                        FileWrite($Log, " " & $Final & "." & $LookFor & " already exists in " & $Folder_Exif & "\" & @CRLF)
                        FileWrite($Log, " " & $Final & "." & $LookFor & " renamed only" & @CRLF & @CRLF)
                        FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Final & "." & $LookFor, 8)
                    Else
                        FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor, 8)
                        FileWrite($Log, " " & $Final & "." & $LookFor & " renamed and moved" & @CRLF & @CRLF)

                    EndIf
                Else
                    FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor, 8)
                EndIf       
            Else
                $Total = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & $t[5]
                If Not FileExists($Default_Folder & "\" & $Folder_NoExif & "\" & $Total & "." & $LookFor) Then
                    For $v=1 to $Duplicated_Deep
                        $Mr_More = ($v+1)
                        If Not FileExists($Default_Folder & "\" & $Folder_NoExif & "\" & $Total & $Mr_More & "." & $LookFor) Then
                            FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_NoExif & "\" & $Total & $Mr_More & "." & $LookFor, 8)
                            FileWrite($Log, " " & $File & " --->>> " & $Total & "." & $LookFor & @CRLF)
                            ExitLoop
                        EndIf
                    Next
                EndIf                               
            EndIf
        WEnd
        FileClose($Search)
        FileClose($Log)
    EndIf
Next
$Log = FileOpen($Program_Folder & "\" & $ExifSorter_Log, 1)
Sleep(1000)
FileMove($Default_Folder & "\" & $Folder_Exif & "\" & "*.*", $Default_Folder & "\" & $Folder_ToSort & "\" & "*.*", 8)
FileMove($Default_Folder & "\" & $Folder_NoExif & "\" & "*.*", $Default_Folder & "\" & $Folder_ToSort & "\" & "*.*", 8)
$Difference = TimerDiff($Begin_Time)
$Period = Round(($Difference)/1000)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "All treatments realized in " & $Period & " sec." & @CRLF & @CRLF & @CRLF)
FileClose($Log)
MsgBox(64, "End of treatment ExifSorter", "All files founds moved to folder " & @CRLF & $Default_Folder & "\" & $Folder_ToSort & "\" & @CRLF & @CRLF & "in " & $Period & " sec.")
TrayTip("Clears any Tray Tip","",0)
EndFunc

Func DupliCatKiller()
$DuplicatedSorter_Log = IniRead("ExifManager.ini", "DuplicatedSorter_Log", "key", "NotFound")
$Duplicated_Deep = IniRead("ExifManager.ini", "Duplicated_Deep", "key", "NotFound")
$begintime = TimerInit()
TrayTip("'DupliCatKiller'", "Launched at " & _NowTime(), 20, 1)
$Log = FileOpen($Program_Folder & "\" & $DuplicatedSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "DupliCatKiller Launch : ")
FileWrite($Log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)
FileWrite($Log, "==============================================================================" & @CRLF)
FileClose($Log)
For $i=1 to $Extension_Nb
    $LookFor = IniRead("ExifManager.ini", "Extension_" & $i, "Key", "NotFound")
    $Search = FileFindFirstFile($Default_Folder & "\" & "*." & $LookFor)
    If $Search = -1 Then
        $Log = FileOpen($Program_Folder & "\" & $DuplicatedSorter_Log, 1)
        FileWrite($Log, @CRLF & "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
        FileWrite($Log, "No File '" & $LookFor & "' found in " & $Default_Folder & @CRLF)
        FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF & @CRLF)
        FileClose($Log)
    Else
        $Log = FileOpen($Program_Folder & "\" & $DuplicatedSorter_Log, 1)
        While 1
            $File = FileFindNextFile($Search)
            If @error Then ExitLoop
            If Not @error Then
                $aInfo = _ImageGetInfo($Default_Folder & "\" & $File)
                $FileDate = _ImageGetParam($aInfo, "DateTimeOriginal")
                $ReplaceIt = StringReplace($FileDate, ":", "")
                $Final = StringReplace($ReplaceIt, " ", "")
                $t = FileGetTime($Default_Folder & "\" & $File, 1)
            EndIf
            If $Final > 0 Then 
                FileWrite($Log, " " & $File & " --->>> " & $Final & "." & $LookFor & " -> " & $Folder_Exif & "\" & @CRLF)
                If FileExists($Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor) Then
                    FileWrite($Log, $Final & "." & $LookFor & " already exists in " & $Folder_Exif & "\" & @CRLF)
                    For $v=1 to $Duplicated_Deep
                        $Mr_More = ($v+1)
                        If Not FileExists($Default_Folder & "\" & $Folder_Exif & "\" & $Final & "_0" & $Mr_More & "." & $LookFor) Then
                            FileWrite($Log, "Okay - " & $Final & "_0" & $Mr_More & "." & $LookFor & @CRLF)
                            FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_Exif & "\" & $Final & "_0" & $Mr_More & "." & $LookFor, 8)                          
                            ExitLoop
                        EndIf
                    Next
                EndIf               
            Else
                $Total = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & $t[5]
                FileWrite($Log, " " & $File & " --->>> " & $Total & "." & $LookFor & @CRLF)
                If FileExists($Default_Folder & $Folder_NoExif & $Total & "." & $LookFor) Then
                    FileWrite($Log, "This name already exists : " & $Total & "." & $LookFor & @CRLF)
                    For $v=1 to $Duplicated_Deep
                        $Mr_More = ($v+1)
                        If Not FileExists($Default_Folder & $Folder_NoExif & $Total & "_0" & $Mr_More & "." & $LookFor) Then
                            FileWrite($Log, "Okay - " & $Total & "_" & $Mr_More & "." & $LookFor & @CRLF)
                            FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_NoExif & "\" & $Total & "_0" & $Mr_More & "." & $LookFor, 8)
                            ExitLoop
                        EndIf
                    Next
                Else
                    FileMove($Default_Folder & "\" & $File, $Default_Folder & $Folder_NoExif & $Total & "." & $LookFor, 8)
                    FileWrite($Log, " " & $File & " --->>> " & $Total & "." & $LookFor & @CRLF)
                EndIf               
            EndIf
        WEnd
        FileClose($Search)
        FileClose($Log)
    EndIf
Next
$dif = TimerDiff($begintime)
$Period = round(($dif)/1000)
$Log = FileOpen($Program_Folder & "\" & $DuplicatedSorter_Log, 1)
Sleep(1000)
FileMove($Default_Folder & "\" & $Folder_Exif & "\" & "*.*", $Default_Folder & "\" & $Folder_ToSort & "\" & "*.*", 8)
FileMove($Default_Folder & "\" & $Folder_NoExif & "\" & "*.*", $Default_Folder & "\" & $Folder_ToSort & "\" & "*.*", 8)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "All treatments realized in " & $Period & " sec." & @CRLF & @CRLF & @CRLF)
FileClose($Log)
MsgBox(64, "End of treatment DupliCatKiller", "All files founds moved to folder " & @CRLF & $Default_Folder & "\" & $Folder_ToSort & "\" & @CRLF & @CRLF & "in " & $Period & " sec.")
TrayTip("clears any tray tip","",0)
EndFunc

Func CopyRightSorter()
$CopyRightSorter_Log = IniRead("ExifManager.ini", "CopyRightSorter_Log", "key", "NotFound")
$CopyRighted_Folder = IniRead("ExifManager.ini", "CopyRighted_Folder", "key", "NotFound")
$begintime = TimerInit()
TrayTip("'CopyRightSorter'", "Launched at " & _NowTime(), 20, 1)
$Log = FileOpen($Program_Folder & "\" & $CopyRightSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "CopyRightSorter Launch : ")
FileWrite($Log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)
FileWrite($Log, "==============================================================================" & @CRLF)
FileClose($Log)
For $i=1 to $Extension_Nb
    $LookFor = IniRead("ExifManager.ini", "Extension_" & $i, "Key", "NotFound")
    $Search = FileFindFirstFile($Default_Folder & "\" & $Folder_ToSort & "\" & "*." & $LookFor)
    If $search = -1 Then
        $Log = FileOpen($Program_Folder & "\" & $CopyRightSorter_Log, 1)
        FileWrite($Log, @CRLF & "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF & @CRLF)
        FileWrite($Log, "No File '" & $LookFor & "' found in " & $Default_Folder & "\" & $Folder_ToSort & @CRLF)
        FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
        FileClose($Log)
    Else
        $Log = FileOpen($Program_Folder & "\" & $CopyRightSorter_Log, 1)
        While 1
            $File = FileFindNextFile($Search)
            If @error Then ExitLoop
            If Not @error Then
                $aInfo = _ImageGetInfo($Default_Folder & "\" & $Folder_ToSort & "\" & $File)
                $CopyRight = _ImageGetParam($aInfo, "Copyright")
                If $CopyRight > 0 Then
                    FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
                    FileWrite($Log, " Files " & $LookFor & " found : " & @CRLF & @CRLF)
                    FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
                    FileWrite($Log, $File & " -->>  get a copyright" & @CRLF)
                    If FileExists($Default_Folder & "\" & $Folder_ToSort & "\" & $CopyRighted_Folder & "\" & $File) Then
                        FileWrite($Log, " " & $File & " -->> Already exists in folder - Please use DupliCatKiller. " & @CRLF & @CRLF)
                    Else
                        FileWrite($Log, $Default_Folder & "\" & $Folder_ToSort & "\" & $CopyRighted_Folder & "\" & $File & "     -->> copyrighted" & @CRLF)
                    EndIf
                Else

                EndIf
            EndIf
        WEnd
        FileClose($Search)
        FileClose($Log)
    EndIf
Next
$dif = TimerDiff($begintime)
$Period = round(($dif)/1000)
Sleep(1000)
$Log = FileOpen($Program_Folder & "\" & $CopyRightSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "All treatments realized in " & $Period & " sec." & @CRLF & @CRLF & @CRLF)
FileClose($Log)
MsgBox(64, "End of treatment CopyRightSorter", "A Log File has been created. Take time to read it please." & @CRLF & @CRLF & "in " & $Period & " sec.")
TrayTip("clears any tray tip","",0)
EndFunc

Func SizeSorter()
$SizeSorter_Log = IniRead("ExifManager.ini", "SizeSorter_Log", "key", "NotFound")
$Picture_Size = IniRead("ExifManager.ini", "Picture_Size", "key", "NotFound")
$Size_Folder = IniRead("ExifManager.ini", "Size_Folder", "key", "NotFound")
$begintime = TimerInit()
TrayTip("'SizeSorter'", "Launched at " & _NowTime(), 20, 1)
$Log = FileOpen($Program_Folder & "\" & $SizeSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "SizeSorter Launch : ")
FileWrite($Log, _NowCalcDate() & " " & _DateTimeFormat( _NowCalc(),5) & @CRLF)
FileWrite($Log, "==============================================================================" & @CRLF)
FileClose($Log)
For $i=1 to $Extension_Nb
    $LookFor = IniRead("ExifManager.ini", "Extension_" & $i, "Key", "NotFound")
    $Search = FileFindFirstFile($Default_Folder & "\" & $Folder_ToSort & "\" & "*." & $LookFor)
    If $Search = -1 Then
        $Log = FileOpen($Program_Folder & "\" & $SizeSorter_Log, 1)
        FileWrite($Log, @CRLF & "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF & @CRLF)
        FileWrite($Log, "No File '" & $LookFor & "' found in " & $Default_Folder & "\" & $Folder_ToSort & @CRLF)
        FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
        FileClose($Log)
    Else
        $Log = FileOpen($Program_Folder & "\" & $SizeSorter_Log, 1)
        FileWrite($Log, " Files " & $LookFor & " found : " & @CRLF & @CRLF)
        FileWrite($Log, "------------------------------------------------------------------------------------------------------------------------------------------------------------" & @CRLF)
        While 1
            $File = FileFindNextFile($Search)
            If @error Then ExitLoop
            If Not @error Then
                $aInfo = _ImageGetInfo($Default_Folder & "\" & $Folder_ToSort & "\" & $File)
                $Width = _ImageGetParam($aInfo, "Width")
                $Height = _ImageGetParam($aInfo, "Height")
                $Calculate = $Width*$Height
                MsgBox(64, "SizeSorter", $File & @CRLF & "Width : " & $Width & " & " & "Height : " & $Height & @CRLF & @CRLF & "Calcul : " & $Calculate)
                If $Calculate < $Picture_Size Then
                    If FileExists($Default_Folder & "\" & $Folder_ToSort & "\" & $Size_Folder & "\" & $File) Then
                        FileWrite($Log, " " & $File & " -->> Already exists in folder - Please use DupliCatKiller." & @CRLF & @CRLF)
                    Else
;                       FileWrite($Log, $File & " -->>  Little pic -> so moved" & @CRLF)
                        MsgBox(64, "SizeSorter", " -->> Little pic -> so moved")
                    EndIf
                Else

                EndIf
            EndIf
        WEnd
        FileClose($search)
        FileClose($Log)
    EndIf
Next
$dif = TimerDiff($begintime)
$Period = round(($dif)/1000)
Sleep(1000)
$Log = FileOpen($Program_Folder & "\" & $SizeSorter_Log, 1)
FileWrite($Log, "================================================================================================

============================================================" & @CRLF)
FileWrite($Log, "All treatments realized in " & $Period & " sec." & @CRLF & @CRLF & @CRLF)
FileClose($Log)
MsgBox(64, "End of treatment SizeSorter", "All files founds moved to folder " & @CRLF & $Default_Folder & "\" & $Folder_ToSort & "\" & @CRLF & @CRLF & "in " & $Period & " sec.")
TrayTip("clears any tray tip","",0)
EndFunc

Func VerifReps()
    $Folder_a = FileFindFirstFile($Default_Folder & "\" & $Folder_Exif & "\*.*")
    If $Folder_a = 1 Then
        MsgBox(48,"Folder is not empty", "The Folder " & $Folder_Exif & @CRLF & " is not empty !")
    Else
        MsgBox(64,"Folder is empty", "The Folder " & $Folder_Exif & " is empty ")
    EndIf
    FileClose($Folder_a)
    $Folder_b = FileFindFirstFile($Default_Folder & "\" & $Folder_NoExif & "\*.*")
    If $Folder_b = 1 Then
        MsgBox(48,"Folder is not empty", "The Folder " & $Folder_NoExif & @CRLF & " is not empty !")
    Else
        MsgBox(64,"Folder is empty", "The Folder " & $Folder_NoExif & " is empty")
    EndIf
    FileClose($Folder_b)
    $Folder_c = FileFindFirstFile($Default_Folder & "\" & $Shoots_Folder & "\*.*")
    If $Folder_c = 1 Then
        MsgBox(48,"Folder is not empty", "The Folder " & $Shoots_Folder & @CRLF & " is not empty !")
    Else
        MsgBox(64,"Folder is empty", "The Folder " & $Shoots_Folder & " is empty")
    EndIf
    FileClose($Folder_c)
EndFunc

Func CapturIt()
    If FileExists($Default_Folder & "\" & $Shoots_Folder) Then
        _ScreenCapture_Capture($Default_Folder & "\" & $Shoots_Folder & "\" & "shoot_" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".jpg")
        TrayTip("CapturIt", "File created", 1, 1)
    Else
        DirCreate($Default_Folder & "\" & $Shoots_Folder)
        _ScreenCapture_Capture($Default_Folder & "\" & $Shoots_Folder & "\" & "shoot_" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".jpg")
        TrayTip("CapturIt", "File created", 1, 1)
    EndIf
    Sleep(2000)
    TrayTip("clears any tray tip","",0)
EndFunc

Func YearMonthSorter()
$Duplicated_Deep = IniRead("ExifManager.ini", "Duplicated_Deep", "key", "NotFound")
$Folder_SortYearMonth = IniRead("ExifManager.ini", "Folder_SortYearMonth", "key", "NotFound")
$begintime = TimerInit()
TrayTip("'YearMonthSorter'", "Launched at " & _NowTime(), 20, 1)
;en test au delà de cette section
For $i=1 to $Extension_Nb
    $LookFor = IniRead("ExifManager.ini", "Extension_" & $i, "Key", "NotFound")
    $Search = FileFindFirstFile($Default_Folder & "\" & $Folder_ToSort & "\" & "*." & $LookFor)
    If $Search = -1 Then
        MsgBox(64, "End of treatment YearMonthSorter", "No file found")
    Else
        While 1
            $File = FileFindNextFile($Search)
            If @error Then ExitLoop
            If Not @error Then
                $aInfo = _ImageGetInfo($Default_Folder & "\" & $Folder_ToSort & "\" & $File)
                $FileDate = _ImageGetParam($aInfo, "DateTimeOriginal")
                $ReplaceIt = StringReplace($FileDate, ":", "")
                $Final = StringReplace($ReplaceIt, " ", "")
                $t = FileGetTime($Default_Folder & "\" & $Folder_ToSort & "\" & $File, 1)
            EndIf
            If $Final > 0 Then 
;               MsgBox(64,"$Final", $Final)
                $variable = StringMid($Final, 1, 6)
;               MsgBox(64,"$6 premiers caractères", $variable)
                If FileExists($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $Final & "." & $LookFor) Then
                    If FileExists($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $Final & "." & $LookFor) Then
                    ;rien
                    Else
;                       DirCreate($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $variable)
;                       FileMove($Default_Folder & "\" & $Folder_ToSort "\" & $File, $Default_Folder & "\" & $Folder_ToSort & "\" & $Final & "." & $LookFor, 8)
                    EndIf
                Else
                    DirCreate($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $variable)
;                   FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_Exif & "\" & $Final & "." & $LookFor, 8)
                EndIf       
            Else
                $Total = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & $t[5]
                $YearMonth =  $t[0] & $t[1]
                If Not FileExists($Default_Folder & "\" & $Folder_ToSort & "\" & $Total & "." & $LookFor) Then
                    For $v=1 to $Duplicated_Deep
                        $Mr_More = ($v+1)
                        If Not FileExists($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $Total & $Mr_More & "." & $LookFor) Then
                            DirCreate($Default_Folder & "\" & $Folder_SortYearMonth & "\" & $YearMonth)
;                           FileMove($Default_Folder & "\" & $File, $Default_Folder & "\" & $Folder_NoExif & "\" & $Total & $Mr_More & "." & $LookFor, 8)
                            ExitLoop
                        EndIf
                    Next
                EndIf                               
            EndIf
        WEnd
        FileClose($Search)
    EndIf
Next
;   FileMove($Default_Folder & "\" & $Folder_ToSort & "\" & "*.*", $Default_Folder & "\" & $Folder_SortYearMonth & "\" & "*.*", 8)
;fin de la section en test
    $dif = TimerDiff($begintime)
    $Period = round(($dif)/1000)
    Sleep(1000)
    MsgBox(64, "End of treatment YearMonthSorter", "All Treatments done" & @CRLF & @CRLF & "in " & $Period & " sec.")
    TrayTip("clears any tray tip","",0)
EndFunc
Link to comment
Share on other sites

I should add the rest of the code.

For external programs in .EXE, they are made from the master one, extracted from the functions, and convert in .exe.

Ini maker : (you must convert it in .exe to launch it from the ExifManager panel)

#Include <date.au3>
#include <file.au3>
#Include <GUIconstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <ProgressConstants.au3>
#include "image_get_info.au3"
#include <ScreenCapture.au3>
;AutoItSetOptionOpt("GUICloseOnESC", 1)

If FileExists("ExifManager.ini") Then
    MsgBox(64,"Already Exists", "An ExifManager.ini already exists." & @CRLF & @CRLF & "To create a new one, you must the old one before.")
Else
    Call("Creation_ini")
EndIf

Func Creation_ini()
    MsgBox(64,"Reference File Creation", "Attention !" & @CRLF & @CRLF & "You are creating the parameters of this program" & @CRLF & @CRLF & "You will have to do it just one time..." & @CRLF & @CRLF & "In case of problem, you can change the file 'ExifManager.ini'")
    $Font = InputBox("Font","Enter the Font : ", "Courrier")
    IniWrite("ExifManager.ini", "Font", "Key", $Font & @CRLF)
    $Program_Folder = InputBox("Program_Folder","Enter the Program Folder : ", "C:\admintools\ExifSorter")
    IniWrite("ExifManager.ini", "Program_Folder", "Key", $Program_Folder & @CRLF)
    $Default_Folder = InputBox("Default_Folder","Enter the Medias Folder : ", "C:\rep_oltr\perso\images\flickr")
    IniWrite("ExifManager.ini", "Default_Folder", "Key", $Default_Folder & @CRLF)
    $Folder_Exif = InputBox("Folder_Exif","Enter the Exif temporary Folder : " & @CRLF & @CRLF & "(Used by this program for treatments)", "Exif")
    IniWrite("ExifManager.ini", "Folder_Exif", "Key", $Folder_Exif & @CRLF)
    $Folder_NoExif = InputBox("Folder_NoExif","Enter the NoExif temporary Folder : " & @CRLF & @CRLF & "(Used by this program for treatments)", "NoExif")
    IniWrite("ExifManager.ini", "Folder_NoExif", "Key", $Folder_NoExif & @CRLF)
    $Folder_ToSort = InputBox("Folder_ToSort","Enter the Folder where the medias will have to be stocked : ", "ToSort")
    IniWrite("ExifManager.ini", "Folder_ToSort", "Key", $Folder_ToSort & @CRLF)
    $Duplicated_Deep = InputBox("Duplicated_Deep","Enter the number of 'try to name' the file : " & @CRLF & @CRLF & "The program will try 'x' incrementaions" & @CRLF & "(example : 20 incrementations by default)", "20")
    IniWrite("ExifManager.ini", "Duplicated_Deep", "Key", $Duplicated_Deep & @CRLF) 
    $CopyRighted_Folder = InputBox("CopyRighted_Folder","Enter the Folder where to stock the Copyrighted medias : ", "CopyRighted")
    IniWrite("ExifManager.ini", "CopyRighted_Folder", "Key", $CopyRighted_Folder & @CRLF)
    $Picture_Size = InputBox("Picture_Size","Enter the resolution to sort medias : " & @CRLF & @CRLF & "by default 500x500 is used" & @CRLF & "(equals to 250.000)", "250000")
    IniWrite("ExifManager.ini", "Picture_Size", "Key", $Picture_Size & @CRLF)
    $Size_Folder = InputBox("Size_Folder","Enter the Folder where to stock the little sized medias : " & @CRLF & @CRLF & "by default LittleSizes is used", "LittleSizes")
    IniWrite("ExifManager.ini", "Size_Folder", "Key", $Size_Folder & @CRLF)
    $Shoots_Folder = InputBox("Shoots_Folder","Enter the Folder where to stock the screens shots : " & @CRLF & @CRLF & "by default Shoots is used", "Shoots")
    IniWrite("ExifManager.ini", "Shoots_Folder", "Key", $Shoots_Folder & @CRLF) 
    $Shoots_Folder = InputBox("Folder_SortYearMonth","Enter the Folder where to move the medias sorted by Year & Month : " & @CRLF & @CRLF & "by default SortYearMonth is used", "SortYearMonth")
    IniWrite("ExifManager.ini", "Folder_SortYearMonth", "Key", $Shoots_Folder & @CRLF)  
    $ExifSorter_Log = InputBox("ExifSorter_Log","Enter the Log name for ExifSorter.exe : ", "ExifSorter_Log.txt")
    IniWrite("ExifManager.ini", "ExifSorter_Log", "Key", $ExifSorter_Log)
    $DuplicatedSorter_Log = InputBox("DuplicatedSorter_Log","Enter the Log name for DuplicatKiller.exe : ", "DuplicatedSorter_Log.txt")
    IniWrite("ExifManager.ini", "DuplicatedSorter_Log", "Key", $DuplicatedSorter_Log)   
    $SizeSorter_Log = InputBox("SizeSorter_Log","Enter the Log name for SizeSorter.exe : ", "SizeSorter_Log.txt")
    IniWrite("ExifManager.ini", "SizeSorter_Log", "Key", $SizeSorter_Log)   
    $CopyRightSorter_Log = InputBox("CopyRightSorter_Log","Enter the Log name for CopyRightSorter.exe : ", "CopyRightSorter_Log.txt")
    IniWrite("ExifManager.ini", "CopyRightSorter_Log", "Key", $CopyRightSorter_Log) 
    
    IniWrite("ExifManager.ini", "Prog_1", "Key", "ExifSorter.exe")
    IniWrite("ExifManager.ini", "Prog_2", "Key", "DupliCatKiller.exe")
    IniWrite("ExifManager.ini", "Prog_3", "Key", "CopyRightSorter.exe")
    IniWrite("ExifManager.ini", "Prog_4", "Key", "SizeSorter.exe")
    IniWrite("ExifManager.ini", "Prog_5", "Key", "SortYearMonth.exe")
    
    $TextButton_Prog_1 = InputBox("TextButton_Prog_1","Enter a button name for 'ExifSorter' : ", "1. Exif / No Exif Sorter")
    IniWrite("ExifManager.ini", "TextButton_Prog_1", "Key", $TextButton_Prog_1 & @CRLF) 
    $TextButton_Prog_2 = InputBox("TextButton_Prog_2","Enter a button name for 'DupliCatKiller' : ", "2. Duplicated Management")
    IniWrite("ExifManager.ini", "TextButton_Prog_2", "Key", $TextButton_Prog_2 & @CRLF) 
    $TextButton_Prog_3 = InputBox("TextButton_Prog_3","Enter a button name for 'CopyRightSorter' : ", "3. CopyRight Sorter")
    IniWrite("ExifManager.ini", "TextButton_Prog_3", "Key", $TextButton_Prog_3 & @CRLF) 
    $TextButton_Prog_4 = InputBox("TextButton_Prog_4","Enter a button name for 'SizeSorter' : ", "4. Resolution Sorter")
    IniWrite("ExifManager.ini", "TextButton_Prog_4", "Key", $TextButton_Prog_4 & @CRLF) 
    $TextButton_Prog_5 = InputBox("TextButton_Prog_5","Enter a button name for 'SortYearMonth' : ", "5. Sort in 'YearMonth'")
    IniWrite("ExifManager.ini", "TextButton_Prog_5", "Key", $TextButton_Prog_5 & @CRLF) 
    $TextButton_Verify = InputBox("TextButton_Verify","Enter a button name for Temporary Folders checking : ", "Verify Temporary Folders")
    IniWrite("ExifManager.ini", "TextButton_Verify", "Key", $TextButton_Verify & @CRLF) 

    $Extension_Nb = InputBox("ExtensionNb","Enter the number of extension to sort : ", "5")
    IniWrite("ExifManager.ini", "Extension_Nb", "Key", $Extension_Nb & @CRLF)   
    For $First_Extension = 1 to $Extension_Nb
        $Extension_Name = InputBox("Extension_Name", "Enter the extension " & $First_Extension & " sur " & $Extension_Nb, "")
        IniWrite("ExifManager.ini", "Extension_" & $First_Extension, "Key", $Extension_Name)
    Next
EndFunc
Link to comment
Share on other sites

And INI example :

[Font]
Key=Courrier
[Program_Folder]
Key=C:\admintools\exifsorter
[Default_Folder]
Key=C:\perso\images

[Folder_Exif]
Key=Exif
[Folder_NoExif]
Key=NoExif
[Folder_ToSort]
Key=ToSort
[Duplicated_Deep]
Key=20
[CopyRighted_Folder]
Key=CopyRighted
[Picture_Size]
Key=250000
[Size_Folder]
Key=LittleSizes
[Shoots_Folder]
Key=Shoots
[Folder_SortYearMonth]
Key=SortYearMonth

[ExifSorter_Log]
Key=ExifSorter_Log.txt
[DuplicatedSorter_Log]
Key=DuplicatedSorter_Log.txt
[SizeSorter_Log]
Key=SizeSorter_Log.txt
[CopyRightSorter_Log]
Key=CopyRightSorter_Log.txt
[Prog_1]
Key=ExifSorter.exe
[Prog_2]
Key=DupliCatKiller.exe
[Prog_3]
Key=CopyRightSorter.exe
[Prog_4]
Key=SizeSorter.exe
[Prog_5]
Key=SortYearMonth.exe
[TextButton_Prog_1]
Key=1. Exif / No Exif Sorter
[TextButton_Prog_2]
Key=2. Duplicated Management
[TextButton_Prog_3]
Key=3. CopyRight Sorter
[TextButton_Prog_4]
Key=4. Size Sorter
[TextButton_Prog_5]
Key=5. Sort in "YearMonth"
[TextButton_Verify]
Key=Verify Temporary Folders

[Extension_Nb]
Key=4
[Extension_1]
Key=jpg
[Extension_2]
Key=gif
[Extension_3]
Key=png
[Extension_4]
Key=jpeg
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...