手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell获取图片名字、文件夹及拍摄时间的例子
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小技巧之从文件获取系统日志

Powershell后台作业、异步操作实例

powershell 将文本转换成表格的另一种可行方式

Powershell脚本的4种执行权限介绍

Powershell小技巧之设置IE代理

PowerShell读取文本文件指定行内容的方法

PowerShell批量文件重命名操作实例

Windows Powershell 执行外部命令

Windows Powershell 快捷键介绍

PowerShell查找分区中最大文件的方法(查找文件并按大小排序)

精品推荐
分类导航