@majlu11 - można to zrobić skryptem w PowerShellu bo darmowe programy mogą wymagać licencji do użytku komercyjnego - na https://duck.ai możesz za darmo zadawać pytania ChatGPT - możesz je zadawać po polsku - ja zadałem po angielsku - da Ci odpowiedź w każdym języku programowania.
Give me PowerShell script that copies photos to a folder name based on thier Exif date
Certainly! Below is a PowerShell script that copies photos from a specified source directory to a destination directory, organizing them into folders based on their EXIF date. The script uses the System.Drawing namespace to read the EXIF data.
Make sure you have the necessary permissions to read the source files and write to the destination directory.
powershell
Copy Code
# Define source and destination directories
$sourceDir = "C:\Path\To\Source\Photos"
$destinationDir = "C:\Path\To\Destination\Photos"
# Load the System.Drawing assembly
Add-Type -AssemblyName System.Drawing
# Get all image files from the source directory
$images = Get-ChildItem -Path $sourceDir -Include *.jpg, *.jpeg, *.png -Recurse
foreach ($image in $images) {
try {
# Load the image
$img = [System.Drawing.Image]::FromFile($image.FullName)
# Get the EXIF property for DateTaken
$propertyId = 0x0132 # DateTimeOriginal
$propertyItem = $img.GetPropertyItem($propertyId)
# Convert the EXIF date to a readable format
$dateTaken = [System.Text.Encoding]::ASCII.GetString($propertyItem.Value).Trim()
$date = Get-Date $dateTaken
# Create a folder name based on the EXIF date
$folderName = $date.ToString("yyyy-MM-dd")
$targetDir = Join-Path -Path $destinationDir -ChildPath $folderName
# Create the target directory if it doesn't exist
if (-not (Test-Path -Path $targetDir)) {
New-Item -ItemType Directory -Path $targetDir | Out-Null
}
# Copy the image to the target directory
Copy-Item -Path $image.FullName -Destination $targetDir
# Dispose of the image object
$img.Dispose()
} catch {
Write-Host "Error processing file $($image.FullName): $_"
}
}
Write-Host "Photos have been copied and organized by EXIF date."
Instructions:
Replace C:\Path\To\Source\Photos with the path to your source directory containing the photos.
Replace C:\Path\To\Destination\Photos with the path to your destination directory where you want the organized folders to be created.
Save the script as a .ps1 file (e.g., CopyPhotosByExifDate.ps1).
Open PowerShell and run the script.
Note:
This script assumes that the images have the DateTimeOriginal EXIF property. If the property is missing, the script will skip that image.
Ensure that you have the necessary permissions to access the files and directories specified.