8

I'm looking for a way to use the command line on windows 10 and 11 to read the File description field from the metadata of a file.

The value of many other fields can be get using wmic as described in answers to this question.

But there seems to be no way to get the value displayed on File description using that method. For example, for the windows explorer.exe, the properties shown in Win11 might look like this

enter image description here

but all wmic displays is the full path to the file:

C:\>wmic datafile where Name="C:\\windows\\explorer.exe" get Description
Description
C:\windows\explorer.exe

Are there ways to get every field shown in the explorer.exe dialog and get the same value as shown there using the command line?

4 Answers 4

8

You can use Powershell's Get-Item to get the properties:

(Get-Item C:\Windows\Explorer.exe).VersionInfo.FileDescription

Result:
Windows Explorer

1
  • Accepting this for its terseness and because it's using now built-in functionality but it's a close one. I also like the exiftool solution and harrymc's for its added value and the reference. Commented Sep 22, 2023 at 18:19
4

If you don't mind using a third party tool, exiftool can do the job:

exiftool -filedescription c:\windows\explorer.exe

enter image description here

2

You may use PowerShell to access the metadata attributes of the file.

The following script which you may store in a .ps1 file and execute in a PowerShell session will get the file description:

$path = 'C:\windows\explorer.exe'
$shell = New-Object -COMObject Shell.Application
$folder = Split-Path $path
$file = Split-Path $path -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)
$shellfolder.GetDetailsOf($shellfile, 34)

Running this script will do this :

PS C:\Temp> .\test.ps1
Windows Explorer

If you wish to list all the possible attributes and their ids, replace the last line of the above script with:

0..287 | Foreach-Object { '{0} = {1}' -f $_, $shellfolder.GetDetailsOf($null, $_) }

and run it, for example, using the PowerShell command:

.\test.ps1 | Out-File C:\Temp\f.txt

This will give an output similar to:

0 = Name
1 = Size
2 = Item type
3 = Date modified
4 = Date created
5 = Date accessed
6 = Attributes
7 = Offline status
etc.

Reference : Enumerate file properties in PowerShell.

1

Use the following cmdlet in Powershell:

(Get-Item C:\Windows\Explorer.exe).VersionInfo | select FileDescription

FileDescription
---------------
Windows Explorer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .