PS: Get Video File Resolution From Folder

less than 1 minute read

Description:

I was wanting a way to view the resolution of each of my video files. Here is the script I have been using for this:

To Resolve:

  1. This script: Given a source directory, this function will recursively get all the video files and display their resolutions.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    
    $Objshell = New-Object -Comobject Shell.Application 
    
          $Filelist = @() 
          $Attrlist = @{} 
          $Details = ( "Frame Height", "Frame Width", "Frame Rate" ) 
       
          $Objfolder = $Objshell.Namespace($Source) 
          For ($Attr = 0 ; $Attr -Le 500; $Attr++) 
          { 
                $Attrname = $Objfolder.Getdetailsof($Objfolder.Items, $Attr) 
                If ( $Attrname -And ( -Not $Attrlist.Contains($Attrname) )) 
                {  
                   $Attrlist.Add( $Attrname, $Attr )  
                } 
          } 
       
          Get-ChildItem $Source -Recurse -Directory | Foreach-Object { 
                $Objfolder = $Objshell.Namespace($_.Fullname) 
                Foreach ($File In $Objfolder.Items()) 
                {
                   Foreach ( $Attr In $Details) 
                   { 
                      $Attrvalue = $Objfolder.Getdetailsof($File, $Attrlist[$Attr]) 
                      If ( $Attrvalue )  
                      {  
                            Add-Member -Inputobject $File -Membertype Noteproperty -Name $("A_" + $Attr) -Value $Attrvalue 
                      }  
                   } 
                   $Filelist += $File 
                   $Filelist.Count 
                } 
          } 
       
          $Filelist | Export-Csv $Outputfile -Delimiter ',' 
          $Filelist | Format-Table
    
  2. Source is maintained under gwFileSystem

Comments