Share via

How i can get file properties -"Title". (Not to be confused with the "File name") using powershell ?

Anonymous
2022-03-09T14:00:22+00:00

pls help )

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. _AW_ 67,231 Reputation points Volunteer Moderator
    2022-03-10T09:48:32+00:00

    Here you go! From https://gist.github.com/woehrl01/5f50cb311f3ec711f6c776b2cb09c34e 

    Function Get-FileMetaData

    {

    <#

    .SYNOPSIS

    Get-FileMetaData returns metadata information about a single file.


    .DESCRIPTION

    This function will return all metadata information about a specific file. It can be used to access the information stored in the filesystem.


    .EXAMPLE

    Get-FileMetaData -File "c:\temp\image.jpg"


    Get information about an image file.


    .EXAMPLE

    Get-FileMetaData -File "c:\temp\image.jpg" | Select Dimensions


    Show the dimensions of the image.


    .EXAMPLE

    Get-ChildItem -Path .\ -Filter *.exe | foreach {Get-FileMetaData -File $_.Name | Select Name,"File version"}


    Show the file version of all binary files in the current folder.

    #>


    param([Parameter(Mandatory=$True)][string]$File = $(throw "Parameter -File is required."))


    if(!(Test-Path -Path $File))

    {

    throw "File does not exist: $File"

    Exit 1

    }


    $tmp = Get-ChildItem $File

    $pathname = $tmp.DirectoryName

    $filename = $tmp.Name


    $hash = @{}

    try{

    $shellobj = New-Object -ComObject Shell.Application

    $folderobj = $shellobj.namespace($pathname)

    $fileobj = $folderobj.parsename($filename)


    for($i=0; $i -le 294; $i++)

    {

    $name = $folderobj.getDetailsOf($null, $i);

    if($name){

    $value = $folderobj.getDetailsOf($fileobj, $i);

    if($value){

    $hash[$($name)] = $($value)

    }

    }

    }

    }finally{

    if($shellobj){

    [System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$shellobj) | out-null

    }

    }

    return New-Object PSObject -Property $hash

    }

    Use it as shown in my previous post.

    $myfile = "C:\Users$junk\Downloads\copyfonts.com_candid.ttf"

    Get-FileMetaData -File $myfile | ForEach-Object {

    if ($\_.Title -ne $null) { Write-Host $\_.Title } 
    

    }

    >Candid

    2 people found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-03-10T11:37:29+00:00

    That's what I was looking for >> getDetailsOf tnx u r my Hero !

    0 comments No comments
  2. Anonymous
    2022-03-10T09:07:49+00:00

    Get-FileMetaData is not a core PowerShell cmdlet. This option is not suitable for me as it requires additional deployments,

    for it to work, it has to get this information from somewhere.
    
    0 comments No comments
  3. _AW_ 67,231 Reputation points Volunteer Moderator
    2022-03-10T06:08:27+00:00

    Hi, you can use the powershell module at:

    https://evotec.xyz/getting-file-metadata-with-powershell-similar-to-what-windows-explorer-provides/ 

    To use it:

    Get-FileMetaData -File "C:\some path\somefont.ttf" | ForEach-Object { 
    
        if ($_.Title -ne $null) { Write-Host $_.Title }
    
    }
    
    0 comments No comments
  4. Anonymous
    2022-03-10T05:35:06+00:00

    Hi OYAZ6111,

    Thanks for your post in Microsoft Community.

    Sorry, I don't particularly understand your question.

    I thought of two possibilities:

    1- You want to copy the "title" of the file alone

    2- You want to add a "title" to the file

    What is your question?

    we look forward to your reply. Thank you for your patience and understanding.

    Kirk | Microsoft Community Support Specialist


    * Beware of scammers posting fake support numbers here.

    * If your problem is not solved, you could reply to the post again and we would continue to provide technical support for you.

    * Please check and vote this answer if it helps as it will be beneficial to more community members reading here.

    0 comments No comments