How can I find the table that shows association of the number to file-properties?
For example: $Duration = $Folder.GetDetailsOf($File, 27)
The duration is #27 in the $File (file-properties).
What key terms or words that I should use in a search?
I have some audio-files that the file name to identify the purpose of the audio-file.
I have other audio-files that use the Track# as the file-name and have put the identity in the file-properties: properties> details> description:
Title, Subtitle, Comments, etc.
And is the similar information available for the directories?
Any help will be appreciated.
Thanks, Tracey
Windows 7, Powershell 5.1
..........................................................
$MediaFiles = @('*.mp3','*.wav','*.wma')
$Directory = 'D:\Users\Public\Public.Language\Pronounce it Perfectly in Spanish 2e\Pronounce it Perfectly in Spanish 2e.Down.Load'
$Shell = New-Object -ComObject Shell.Application
Get-ChildItem -Path $Directory -Recurse -Include $MediaFiles |
ForEach-Object {
$Folder = $Shell.Namespace($_.DirectoryName)
$File = $Folder.ParseName($_.Name)
$Duration = $Folder.GetDetailsOf($File, 27)
[PSCustomObject] @{
Name = $_.Name
Duration = $Duration
Size = $_.length
Directory = $_.DirectoryName
}
} | Export-Csv -Path 'D:\Temp\MP3.WAV\MediaSE.csv' -NoTypeInformation -Encoding UTF8
Read-Host -Prompt "Press any key to continue"
It’s hard to find that information. I found a list for Windows 7 through this StackOverflow post listing the properties in Windows 11. There are some variations between OS versions.
If you want to get a list of properties and their corresponding number, you can use this snippet
$Directory = 'D:\Users\Public\Public.Language\Pronounce it Perfectly in Spanish 2e\Pronounce it Perfectly in Spanish 2e.Down.Load'
$Shell = New-Object -ComObject Shell.Application
$Folder = $Shell.Namespace($Directory)
1..512 | ForEach-Object {
$prop = $Folder.GetDetailsOf($null, $_)
if($prop){
[PSCustomObject] @{
Number = $_
Property = $prop
}
}
}
You should see a long list like this
Number Property
------ --------
1 Size
2 Item type
3 Date modified
4 Date created
5 Date accessed
6 Attributes
7 Offline status
8 Availability
9 Perceived type
10 Owner
11 Kind
12 Date taken
13 Contributing artists
14 Album
15 Year
16 Genre
17 Conductors
18 Tags
19 Rating
20 Authors
21 Title
22 Subject
23 Categories
24 Comments
25 Copyright
26 #
27 Length
# truncated
You can also use this technique to extract all the available properties/values on a given file. This snippet will pull a sample wav, mp3, and wma file… assuming one exists somewhere within this directory.
$MediaFiles = '*.mp3', '*.wav', '*.wma'
$Directory = 'D:\Users\Public\Public.Language\Pronounce it Perfectly in Spanish 2e\Pronounce it Perfectly in Spanish 2e.Down.Load'
$Shell = New-Object -ComObject Shell.Application
foreach($type in $MediaFiles){
$sample = Get-ChildItem -Path $Directory -Recurse -Include $type | Select-Object -First 1
if($sample){
$sample | ForEach-Object {
$Folder = $Shell.Namespace($_.DirectoryName)
$File = $Folder.ParseName($_.Name)
1..512 | ForEach-Object {
$value = $Folder.GetDetailsOf($file, $_)
if($value){
[PSCustomObject] @{
File = $sample.FullName
Number = $_
Property = $Folder.GetDetailsOf($null, $_)
Value = $value
}
}
}
}
}
}
2 Likes
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.