我是靠谱客的博主 勤劳哈密瓜,这篇文章主要介绍Powershell获取图片名字、文件夹及拍摄时间的例子,现在分享给大家,希望可以做个参考。

如果你想要整理你的图片档案,这里有一段代码它能从图片文件获取相关的拍摄信息。

这个例子使用一个系统函数获得”我的图片”的路径,接着从其目录和子目录查询所有的文件。获得的结果通过管道符传递给函数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

最后

以上就是勤劳哈密瓜最近收集整理的关于Powershell获取图片名字、文件夹及拍摄时间的例子的全部内容,更多相关Powershell获取图片名字、文件夹及拍摄时间内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(207)

评论列表共有 0 条评论

立即
投稿
返回
顶部