Added option to update DateTimeOriginal

This commit is contained in:
Chris Stuurman 2025-01-24 15:51:18 +02:00
parent 36c7a31846
commit 47ff2b7632
3 changed files with 163 additions and 31 deletions

BIN
log6.txt Normal file

Binary file not shown.

119
log7.txt Normal file
View File

@ -0,0 +1,119 @@
--------------------------------------------------------------------------------
Friday 2025-01-24 12:32:01
D:\Users\Chris\Pictures\2025-01-24 org\2025_01_06
"D:\Users\Chris\Pictures\2025-01-24/20250106_181341.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181347.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181434.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181437.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181503.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181508.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181516.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181518.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181519.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181520.jpg" moved to destination subfolder "2025_01_06"!
"D:\Users\Chris\Pictures\2025-01-24/20250106_181521.jpg" moved to destination subfolder "2025_01_06"!
D:\Users\Chris\Pictures\2025-01-24 org\2025_01_08
"D:\Users\Chris\Pictures\2025-01-24/20250108_205037.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205046.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205051.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205057.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205102.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205107.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205112.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205118.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205125.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205131.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205137.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205146.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205151.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205159.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205204.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205209.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205213.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205218.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205223.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205228.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205234.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205240.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205244.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205336.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205340.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205345.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205349.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205354.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205359.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205404.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205410.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205414.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205420.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205425.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205428.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205433.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205437.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205442.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205448.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205453.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205651.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205726.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205750.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205801.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205905.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_205927.jpg" moved to destination subfolder "2025_01_08"!
"D:\Users\Chris\Pictures\2025-01-24/20250108_210148.jpg" moved to destination subfolder "2025_01_08"!
D:\Users\Chris\Pictures\2025-01-24 org\2025_01_14
"D:\Users\Chris\Pictures\2025-01-24/20250114_101942.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102008.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102014.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102020.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102022.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102025.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102030.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102037.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102558.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102600.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102602.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102604.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102607.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102611.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102614.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102632.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102637.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102755.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102757.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102759.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102800.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102801.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102802.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102804.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102807.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102812.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102829.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102835.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102842.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102844.jpg" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102849.jpg" moved to destination subfolder "2025_01_14"!
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (3).jpg" : File has no usable ExifData! Earliest file time is 2025-01-09 13:31:08
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (5).jpg" : File has no usable ExifData! Earliest file time is 2025-01-10 21:27:36
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (8).jpg" : File has no usable ExifData! Earliest file time is 2025-01-12 19:02:59
"D:\Users\Chris\Pictures\2025-01-24/20250114_102143.mp4" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102405.mp4" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102547.mp4" moved to destination subfolder "2025_01_14"!
"D:\Users\Chris\Pictures\2025-01-24/20250114_102645.mp4" moved to destination subfolder "2025_01_14"!
--------------------------------------------------------------------------------
Friday 2025-01-24 15:48:47
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (3).jpg" : File has no usable ExifData! Earliest file time is 2025-01-09 13:31:08
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (5).jpg" : File has no usable ExifData! Earliest file time is 2025-01-10 21:27:36
--------------------------------------------------------------------------------
Friday 2025-01-24 15:49:11
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (3).jpg" : File has no usable ExifData! Earliest file time is 2025-01-09 13:31:08
D:\Users\Chris\Pictures\2025-01-24 org\2025_01_09
"D:\Users\Chris\Pictures\2025-01-24/Monster High (3).jpg" moved to destination subfolder "2025_01_09"!
Skipped "D:\Users\Chris\Pictures\2025-01-24\Monster High (5).jpg" : File has no usable ExifData! Earliest file time is 2025-01-10 21:27:36
D:\Users\Chris\Pictures\2025-01-24 org\2025_01_10
"D:\Users\Chris\Pictures\2025-01-24/Monster High (5).jpg" moved to destination subfolder "2025_01_10"!

View File

@ -45,37 +45,50 @@ $Main =
$medialist.Add($File)
}
foreach ($mediafile in $medialist) {
$xfoutput = @(C:\Tools\exiftool\exiftool.exe $mediafile.FullName)
$sourcefilefullname = $mediafile.FullName
# Write-Output $sourcefilefullname | Tee-Object -FilePath $LogPath -Append
$exiflist = @{}
foreach ($tagvalpair in $xfoutput) {
$arr=@($tagvalpair -split ":", 2)
$key=$arr[0] -replace ' ' -replace '/','_'
$value=$arr[1].Trim()
$exiflist[$key] = $value
}
# Write-Output "`n------ xfoutput ---------" $mediafile.Name $xfoutput
# Write-Output "`n------ exiflist ---------" $mediafile.Name $exiflist
$CreateDate = cv2datetime $exiflist['CreateDate']
$Date_TimeOriginal = cv2datetime $exiflist['Date_TimeOriginal']
$FileCreationDate_Time = cv2datetime $exiflist['FileCreationDate_Time']
$FileModificationDate_Time = cv2datetime $exiflist['FileModificationDate_Time']
$FileAccessDate_Time = cv2datetime $exiflist['FileAccessDate_Time']
$filenamedate = validatedate $mediafile.Name
$datestr = $null
$datetaken = getearliest $CreateDate $Date_TimeOriginal
if (-not($null -eq $datetaken)) {
$datestr = $datetaken.ToString('yyyyMMdd')
}
elseif (-not($null -eq $filenamedate)) {
Write-Output """$sourcefilefullname"" : File has no usable ExifData. Using date in filename." | Tee-Object -FilePath $LogPath -Append | Write-Host -ForegroundColor Yellow
$datestr = $filenamedate.ToString('yyyyMMdd')
}
else {
$earliest = getearliest $FileCreationDate_Time $FileModificationDate_Time $FileAccessDate_Time
$file_time = $earliest.ToString('yyyy-MM-dd HH:mm:ss')
Write-Output "Skipped ""$sourcefilefullname"" : File has no usable ExifData! Earliest file time is $file_time" | Tee-Object -FilePath $LogPath -Append | Write-Host -ForegroundColor DarkRed
$gettime = $true
while ($gettime) {
$gettime = $false
$xfoutput = @(C:\Tools\exiftool\exiftool.exe $mediafile.FullName)
$sourcefilefullname = $mediafile.FullName
# Write-Output $sourcefilefullname | Tee-Object -FilePath $LogPath -Append
$exiflist = @{}
foreach ($tagvalpair in $xfoutput) {
$arr=@($tagvalpair -split ":", 2)
$key=$arr[0] -replace ' ' -replace '/','_'
$value=$arr[1].Trim()
$exiflist[$key] = $value
}
# Write-Output "`n------ xfoutput ---------" $mediafile.Name $xfoutput
# Write-Output "`n------ exiflist ---------" $mediafile.Name $exiflist
$CreateDate = cv2datetime $exiflist['CreateDate']
$Date_TimeOriginal = cv2datetime $exiflist['Date_TimeOriginal']
$FileCreationDate_Time = cv2datetime $exiflist['FileCreationDate_Time']
$FileModificationDate_Time = cv2datetime $exiflist['FileModificationDate_Time']
$FileAccessDate_Time = cv2datetime $exiflist['FileAccessDate_Time']
$filenamedate = validatedate $mediafile.Name
$datestr = $null
$datetaken = getearliest $CreateDate $Date_TimeOriginal
if (-not($null -eq $datetaken)) {
$datestr = $datetaken.ToString('yyyyMMdd')
}
elseif (-not($null -eq $filenamedate)) {
Write-Output """$sourcefilefullname"" : File has no usable ExifData. Using date in filename." | Tee-Object -FilePath $LogPath -Append | Write-Host -ForegroundColor Yellow
$datestr = $filenamedate.ToString('yyyyMMdd')
}
else {
$earliest = getearliest $FileCreationDate_Time $FileModificationDate_Time $FileAccessDate_Time
$file_time = $earliest.ToString('yyyy-MM-dd HH:mm:ss')
Write-Output "Skipped ""$sourcefilefullname"" : File has no usable ExifData! Earliest file time is $file_time" | Tee-Object -FilePath $LogPath -Append | Write-Host -ForegroundColor DarkRed
do {
$inp = Read-Host "Update file's CreateDate property with this date? (y/N)"
}
while(($inp -ne "Y") -and ($inp -ne "N") -and ($inp -ne "") -and ($null -ne $inp))
if ($inp -eq "Y") {
Write-Output "C:\Tools\exiftool\exiftool.exe -DateTimeOriginal=""$file_time"" ""$sourcefilefullname"""
C:\Tools\exiftool\exiftool.exe -DateTimeOriginal="$file_time" "$sourcefilefullname"
$gettime = $true
}
}
}
$sourcefiledir = "$($mediafile.Directory)"
#Write-Output $time_arr