根据照片名修改文件创建修改时间及EXIF
2022-6-29 乱云飞
# $path = $pwd.Path+'\Screenshots\' $path = $pwd.Path+'\Camera\' $EXIF = 0 if ($EXIF -and $(Read-Host "确认修改EXIF请输入EXIF") -ceq "EXIF") { $EXIF = 1 } foreach ($file in ls $path) { $NAME = $file.Name if ($file.Name -match "^([^\d]*?)[_-]?(\d{8})-?(\d{6}.*)$") { $file.MoveTo($path+$matches[1]+'_'+$matches[2]+'_'+$matches[3]) } elseif ($file.Name -match "^([^\d]*?)[_-]?(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2}.*)$") { $M = $matches $file.MoveTo($path+$M[1]+'_'+$M[2]+$M[3]+$M[4]+'_'+$M[5]+$M[6]+$M[7]) } if ($file.Name -match "^[^\d]*(\d{4})(\d{2})(\d{2})_(\d{2})(\d{2})(\d{2}).*$") { $M = $matches $date = $($M[1]+'/'+$M[2]+'/'+$M[3]+' '+$M[4]+':'+$M[5]+':'+$M[6]) if ($EXIF) { $time = $M[1]+':'+$M[2]+':'+$M[3]+'-'+$M[4]+':'+$M[5]+':'+$M[6] jhead -mkexif $path$file jhead "-ts$time" $path$file } $file.creationtime = $date $file.lastwritetime = $date $file.lastaccesstime = $date $NAME+'成功修改 ->'+$file.Name } else { $NAME+'修改失败!!!!!!!!' } } pause本文链接:http://80c.cc/ez/541.html
发表评论: