Powershell Command To Get File Properties

Posted on by admin
Powershell Command To Get File Properties
  1. Powershell Command To Get File Properties In Texas

Powershell Command To Get File Properties In Texas

February 6th, 2014Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to obtain metadata from photo files.Hey, Scripting Guy! I need some help. I have thousands of photo files on my computer.

I need to bring some order to them. I know that I can use Get-ChildItem from Windows PowerShell, and I can find the size of files and names of files. But I need to access information that is more specific to the photos, such as what camera was used, what the F-stop was, and the photo resolution. I know there are expensive software programs that might provide this information, but the information must come from somewhere, and maybe, just maybe, you can tell Windows PowerShell where that location is?—RRHello RR,Microsoft Scripting Guy, Ed Wilson, is here. It is just a couple days until the Windows PowerShell Saturday event in Charlotte.

If you have not yet registered, I think there are a couple of tickets left, so don’t delay too much or they will be gone. Steely dan wav youtube. The list of speakers reads like a who’s who in the Windows PowerShell world.

Powershell create new file

In fact, six of the speakers at our event in Charlotte are also going to be speaking at the Windows PowerShell Summit in Seattle in April. To register, go to.Note This is the fourth in a series of posts that talk about working with files and folders by using Windows PowerShell.You should read the previous posts:.Commonly filled out metadata for image files contains the camera, the F-stop, resolution, and other useful information about the photo. This can be extremely useful for anyone who takes photos. The image metadata is easily found from the File tab for the photo by clicking Properties, then Details. The following image shows typical photo metadata:When using the content view in File Explorer in Windows 8.1, a thumbnail appears with the dimensions of the photo, as shown here:To use Windows PowerShell to examine this type of metadata means using the Shell.Application COM object, connecting to a file, and then walking through the metadata property bag. This technique is a bit cumbersome. Luckily, I can use the same function I wrote yesterday to accomplish this task.Note The complete is available on the Script Center Repository.

Get

Make sure to store resultsBecause it is possible that the script needs to iterate through thousands of photos, and for each photo it needs to search several hundred metadata attributes, the script will take some time to run. The best thing to do is to store the results in a variable. This will allow sorting and post collection processing of the data following the run.The Get-FileMetaDataReturnObject.ps1 script contains a single function. The function is the Get-FileMetadata function. I load the function in the Windows PowerShell ISE, and run it to copy the function into memory. After I have done that, I call the function and pass it an array of folder paths. I get the array of folder paths by using the Get-ChildItem cmdlet.

Here is the command that performs a recursive lookup of a folder named pics and pulls out the directory paths in that folder. This is a single line command that has wrapped.$picMetadata = Get-FileMetaData -folder (Get-childitem E:pics -Recurse -Directory).FullNameAfter the function completes running, I examine the contents of the $picMetaData variable to see what pieces of metadata are filled out. As shown in the following image, there is a decent amount of metadata supplied:After perusing the list of metadata, I decide that I am interested in the camera model, dimensions of the photo, the f-stop, flash mode, iso speed, exposure time, focal length, size, and of course, the path to the photo. It is as easy as picking out chocolates from a candy box.

Because I have stored the returned objects in the $picMetadata variable, I pipe it to the Select-Object cmdlet to produce the output.