Jump to content

Recommended Posts

Posted

hello world

over the years my wife "accidentally" took photo bursts when taking pictures with her cell phone.  so digging through our family album (several thousand files) and would like to see if I could find instances where these bursts happen so I can manually go and delete them.  the way I was thinking, because all files are named with date_time (with seconds included at the end of the file names), is that I could find files that have the same name but only the last 2 characters (the seconds) are different.

example scenarios that could be identified (the last 2 digits are seconds so basically each picture was taken seconds between each other):

 
 
0
 Advanced issue found
 
 
Quote

 

20201219_045217.jpg

20201219_045218.jpg

20201219_045219.jpg

20201219_045220.jpg

...

 

sometimes the pictures were taken within the same second which are represented like this

 
 
0
 Advanced issue found
 
 
Quote

 

2017-02-01 11.32.44-1.jpg

2017-02-01 11.32.44-2.jpg

2017-02-01 11.32.44-3.jpg

...

 

so I was thinking if there are multiple file names with the same name except the last 2 characters then there's a good chance that's where there's a burst

here is what I have started but want to see if this is the best way to go about it....

$file_paths_array = _FileListToArrayRec($album_dir, "*.jpg", 1, 1, 1, 2)

    For $x = 1 To UBound($file_paths_array) - 1
        $full_file_path = $file_paths_array[$x]

        $file_path = Get_File_Path($full_file_path)
        $file_name = Get_File_Name($full_file_path)

        $search = FileFindFirstFile($file_path & "\" & stringtrimright($file_name, 6))

        if $search <> -1 Then
        EndIf
    Next


Func Get_File_Path($sPath) ;credit to MrCreator
    $sPath = StringRegExpReplace($sPath,  '\\[^\\]*$', '')
    Return $sPath
EndFunc   ;==>Get_File_Path

Func Get_File_Name($sPath) ;credit to Melba32
    $sFileName = StringRegExpReplace($sPath, "^.*\\", "")
    Return $sFileName
EndFunc   ;==>Get_File_Name

 

Posted

Maybe this would work for you :

#include <Constants.au3>
#include <File.au3>
#include <Date.au3>

Global Const $IMAGE_DIR = "C:\Users\Nine\Pictures\Temp"

Local $aFiles = _FileListToArrayRec ($IMAGE_DIR, "*.jpg",  $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH)
If @error or $aFiles[0] < 2 Then Exit MsgBox ($MB_SYSTEMMODAL,"","No file to compare")
Local $sDrive, $sDir, $sFileName, $sExtension
Local $sDrivePrev, $sDirPrev, $sFileNamePrev, $sExtensionPrev
_PathSplit ($aFiles[1], $sDrivePrev, $sDirPrev, $sFileNamePrev, $sExtensionPrev)
Local $sDecodedDatePrev = DecodeDate ($sFileNamePrev), $sDecodedDate
For $i = 2 to $aFiles[0]
  _PathSplit ($aFiles[$i], $sDrive, $sDir, $sFileName, $sExtension)
  $sDecodedDate = DecodeDate ($sFileName)
  If $sDrivePrev = $sDrive And $sDirPrev = $sDir Then
    If _DateDiff ('s', $sDecodedDatePrev, $sDecodedDate) <= 1 Then ConsoleWrite ($aFiles[$i-1] & " | " & $aFiles[$i] & @CRLF)
  EndIf
  $sDrivePrev = $sDrive
  $sDirPrev = $sDir
  $sFileNamePrev = $sFileName
  ; $sExtensionPrev = $sExtension
  $sDecodedDatePrev = $sDecodedDate
Next

Func DecodeDate ($sDate)
  $sDate = StringLeft(StringRegExpReplace($sDate, "([._:\-\/ ])", ""), 14)
  Return StringRegExpReplace($sDate,"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})","$1/$2/$3 $4:$5:$6")
EndFunc

_DateDiff is necessary in case dates change minute (2010-10-10_12.12.59 vs 2010-10-10_12.13.00)

Posted
1 hour ago, gcue said:

(several thousand files)     ...    so I can manually go and delete them

A huge task  :sweating:
Maybe you could get into an array all the "duplicates" file names, so you could FileMove (or delete) them

Here is a try

#include <Array.au3>

 Global $aArray[7] = ["20201219_045217.jpg", "20201219_045218.jpg", _ 
        "20201219_045219.jpg", "20201219_045220.jpg", _ 
        "2017-02-01 11.32.44-1.jpg", "2017-02-01 11.32.44-2.jpg", _ 
        "2017-02-01 11.32.44-3.jpg"] 

Global $aRes = GetDups($aArray)
_ArrayDisplay($aRes)


Func GetDups($aArray)
  Local $oDup = ObjCreate("Scripting.Dictionary")
  Local $oRes = ObjCreate("Scripting.Dictionary")
  For $i = 0 To UBound($aArray) - 1
    $tmp = StringTrimRight($aArray[$i], 6)
    If Not $oRes.Exists($tmp) Then  
      $oRes($tmp) = 1
    Else
      $oDup($aArray[$i]) = 1
    EndIf
  Next
  Return $oDup.Keys()  
EndFunc

 

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
×
×
  • Create New...