The Get-ChildItem command in PowerShell is used to get one more item in the specified location. When we specify the file path, Get-ChildItem gets the file object and uses the Format-List * to get file metadata and display it.
In this article, we will discuss how to use the Get-ChildItem command to get file metadata and get mp3 file metadata.
PowerShell Get File Metadata
Use the Get-ChildItem cmdlet in PowerShell to get the file specified and use the Format-List * to get the file properties or metadata and display it on the terminal.
Get-ChildItem .\powershell-read-file-line-by-line.png | Format-List *
In the PowerShell script, we used the Get-ChildItem command to get the file object. It then passes the file object Format-List * to get file metadata.
The output of the above script gets file metadata for the file powerShell-read-file-line-by-line-.jpg is:
Cool Tip: How to read file line by line in PowerShell!
PowerShell Get mp3 file metadata
The Get-ChildItem command with Format-List * retrieves mp3 file metadata.
Get-ChildItem .\PowerShell-Check-File-Exists.mp4 | Format-List *
In the above PowerShell script, the Get-ChildItem command gets the mp3 file object and pipes it to Format-List. The Format-List * lists all the mp3 file properties and displays them on the terminal.
The output of the above script gets mp3/mp4 file metadata like file name, mp3 file length, its creation date, lastwritetime, etc.
Cool Tip: How to get file owner name using PowerShell!
Conclusion
I hope the above article to get file metadata in PowerShell is helpful to you.
Use the Get-ChildItem command in PowerShell the get one or more items from the specified location and use Format-List * to list all the file properties. The file can be text, image, mp3, video, or audio.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.