根据照片名修改文件创建修改时间及EXIF - 洛阳翼展电脑


根据照片名修改文件创建修改时间及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
0

发表评论:

VirtualCamera:在录像机中虚拟一个通道显示电脑桌面、视频文件、USB摄像头~
预ICP备10086-001号 © 翼展网/80C.CC 技术支持/洛阳翼展科技
TEL / 13213610060 QQ / 345794501
Powered by emlog