Powershell-使用“拍摄日期"属性重命名文件 [英] Powershell - rename file using Date Taken attribute

查看:144
本文介绍了Powershell-使用“拍摄日期"属性重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的三星手机上有一堆图像和视频.我将这些图像复制到USB,然后复制到PC上.

I have a stack load of images and videos on my Samsung phone. I copied these images to a USB then onto my PC.

我想使用Powershell根据文件的接受日期"属性重命名这些文件.

I want to use Powershell to rename these files based on their Date Taken attribute.

所需格式= yyyy-MM-dd HH.mm.ss ddd

我一直在使用Powershell脚本(请参见下文),该脚本使用Date Modified属性可以很好地完成此操作,但是上面的副本以某种方式改变了我的Date Modified值(WTH!),所以我现在不能使用它(因为它不准确).

I have been using a Powershell script (see below) that does this beautifully using the Date Modified attribute, but the copy above somehow changed the Date Modified value on me (WTH!), so I can't use that now (as its not accurate).

Get-ChildItem | Rename-Item -NewName {$_.LastWriteTime.ToString("yyyy-MM-dd HH.mm.ss ddd") + ($_.Extension)}

总而言之,有没有一种方法可以基于拍摄日期"文件属性来更改文件名?我在网上看到的建议要求使用.NET System.Drawing.dll和复杂的代码(我敢肯定它可以工作,但是该死的很丑).

In summary - is there a way to change the file name based on the Date Taken file attribute? Suggestions I have seen online require use of the .NET System.Drawing.dll and convoluted code (I'm sure it works, but damn its ugly).

GG

推荐答案

请结帐设置为PhotographNameAsDateTimeTaken Powershell模块.它从图片中提取日期和时间,并将其更改为图片的名称.

Please checkout Set-PhotographNameAsDateTimeTaken Powershell module. It extract date and time from the picture and change name of the picture to it.

它允许使用-Recurse -Replace和-Verbose参数.默认情况下,它将在与您的工作目录相同的级别上创建reuslt文件夹.

It allows to use -Recurse -Replace and -Verbose parameter. By default it will create reuslt folder at the same level as your working dir.

如果您需要更改目标名称的格式,可以在此处找到代码.

If you need change the format of the target names the code can be found here.

这篇关于Powershell-使用“拍摄日期"属性重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆