电源外壳。拉相机属性以附加到文件名

时间:2014-09-09 15:54:43

标签: powershell

我有一个PowerShell脚本,适用于单个摄像头,可以将图像和电影从相机复制并移动到两个存储库。我们现在正在实现多个摄像头,所以我需要一种方法来确保文件名是唯一的,存储在文件共享上。

问题是我不确定如何从相机或存储设备中提取唯一的设备ID。我试图拉EXIF数据,但似乎这台相机没有在EXIF上写一个唯一的序列。所以这给我留下了一个下拉/手动输入选项以附加到文件名,或者可能是yyyymmddhhmmss所以每个文件都有很小的机会成为副本。

我希望尽可能使用户友好,因为用户在技术上并不合适。

思想?

$todaysDate = Get-Date -format yyyyMMdd
$destinationFolderArchive = "\\fileserver\1\$todaysDate"
$destinationFolderWorking = "\\fileserver\2\$todaysDate"
$mydrive=(GWmi Win32_LogicalDisk | ?{$_.VolumeName -eq 'CAMERA'} | %{$_.DeviceID})
$IncludeFiles = ("*.jpg","*.avi","*.mpg","*.mov")

if (!(Test-Path -path $destinationFolderArchive)) {New-Item $destinationFolderArchive -Type Directory}
if (!(Test-Path -path $destinationFolderWorking)) {New-Item $destinationFolderWorking -Type Directory}

Get-ChildItem -Path $mydrive -Recurse -Include $IncludeFiles | Copy-Item -Destination                   
$destinationFolderArchive -verbose
Get-ChildItem -Path $mydrive -Recurse -Include $IncludeFiles  | Move-Item -Destination
$destinationFolderWorking -verbose

Write-Host "The file sync is complete. Press any key to continue."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

1 个答案:

答案 0 :(得分:0)

老实说,您可以做的最简单的事情是使用The Scripting Guys的脚本:Get-FileMetaDataavailable on the TechNet Script Center)。然后,您可以将图片复制到临时文件夹,针对该文件夹运行脚本,并使用Switch对其进行排序。这是它将返回的数据的示例:

Name                  : Gold KATA by Patrick Rochon.jpg
Size                  : 238 KB
Item type             : JPEG image
Date modified         : 8/7/2013 8:20 AM
Date created          : 8/7/2013 8:19 AM
Date accessed         : 8/7/2013 8:19 AM
Attributes            : A
Perceived type        : Image
Owner                 : Domain\TMTech
Kind                  : Picture
Date taken            : ‎4/‎14/‎2013 ‏‎10:38 PM
Tags                  : bulb; kata; led; light art; light painting; long exposure; performance; 
                        photography; dance; martial art
Rating                : Unrated
Authors               : Patrick Rohon
Title                 : The light painting KATA  is the expression of the light we move and create 
                        everyday and  the trace we leave behind.
Subject               : The light painting KATA  is the expression of the light we move and create 
                        everyday and  the trace we leave behind.
Copyright             : Copyright PatrickRochon©2013
Camera model          : NIKON D600
Dimensions            : ‪1200 x 780‬
Camera maker          : NIKON CORPORATION
Program name          : Adobe Photoshop CS5 Macintosh
Computer              : Digital_Ghost (this computer)
Filename              : Gold KATA by Patrick Rochon.jpg
Bit depth             : 24
Horizontal resolution : ‎72 dpi
Width                 : ‎1200 pixels
Vertical resolution   : ‎72 dpi
Height                : ‎780 pixels
Shared                : No
Folder name           : My Pictures
Folder path           : C:\Users\TMTech\My Pictures
Folder                : My Pictures (C:\Users\TMTech)
Path                  : C:\Users\TMTech\My Pictures\Gold KATA by Patrick Rochon.jpg
Type                  : JPEG image
Link status           : Unresolved
EXIF version          : 0230
Exposure bias         : ‎0 step
Exposure program      : Manual
Exposure time         : ‎33 sec.
Flash mode            : No flash, compulsory
ISO speed             : ISO-100
Max aperture          : 0
Metering mode         : Center Weighted Average
Orientation           : Normal
Program mode          : Manual
Saturation            : Low saturation
White balance         : Manual

你需要更多的帮助吗?