如果你想要整理你的图片档案,这里有一段代码它能从图片文件获取相关的拍摄信息。
这个例子使用一个系统函数获得”我的图片”的路径,接着从其目录和子目录查询所有的文件。获得的结果通过管道符传递给函数Get-DateTaken,它将返回这些图片的名字、文件夹及照片的拍摄日期。
function Get-DateTaken { param ( [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [Alias('FullName')] [String] $Path ) begin { $shell = New-Object -COMObject Shell.Application } process { $returnvalue = 1 | Select-Object -Property Name, DateTaken, Folder $returnvalue.Name = Split-Path $path -Leaf $returnvalue.Folder = Split-Path $path $shellfolder = $shell.Namespace($returnvalue.Folder) $shellfile = $shellfolder.ParseName($returnvalue.Name) $returnvalue.DateTaken = $shellfolder.GetDetailsOf($shellfile, 12) $returnvalue } } $picturePath = [System.Environment]::GetFolderPath('MyPictures') Get-ChildItem -Path $picturePath -Recurse -ErrorAction SilentlyContinue | Get-DateTaken
原文地址:Getting DateTaken Info from Pictures
心得:
学习下这种管道直接传给自创函数的方法。
本文链接: https://www.pstips.net/getting-datetaken-info-from-pictures.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
GetDetailsOf($shellfile, 12)这里好像有笔误,得不出结果,似乎应为 3http://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
测试过程中确实没有看到日期。。。。看到差不多那个意思,我就没测试了。