Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $a=[reflection.assembly]::LoadWithPartialName("System.Drawing")
- $paths = Get-ChildItem -Recurse -Filter "*.jpg" "f:\photo\"
- $date = Get-Date "1.1.2013"
- #$paths = $paths | ? {$_.CreationTime -lt $date}
- #$paths = @($paths[0])
- function Get-DateTaken($path){
- $pic = New-Object System.Drawing.Bitmap($path)
- try{
- $bytes = $pic.GetPropertyItem(36867).Value
- $ExifDtString=[System.Text.Encoding]::ASCII.GetString($bytes)
- [datetime]::ParseExact($ExifDtString,"yyyy:MM:dd HH:mm:ss`0",$Null)
- }
- finally{
- $pic.Dispose()
- }
- }
- $c = 0;
- $t = $paths.Count
- $date = 0
- foreach ($item in $paths){
- Write-Progress -Activity "Update date" -status "dd" -PercentComplete (($c++)/$t*100)
- try {
- $date = Get-DateTaken $item.FullName
- $date = New-Object datetime -ArgumentList $date.Ticks,([System.DateTimeKind]::Local)
- $item.LastWriteTime = $date
- }
- catch{
- Write-Warning "item $($item.FullName) skipped.`n $($error[0])`n"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment