-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathAdd-FileDetails.ps1
More file actions
50 lines (43 loc) · 1.37 KB
/
Add-FileDetails.ps1
File metadata and controls
50 lines (43 loc) · 1.37 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<#
.SYNOPSIS
<A brief description of the script>
.DESCRIPTION
<A detailed description of the script>
.PARAMETER <paramName>
<Description of script parameter>
.EXAMPLE
<An example of using the script>
#>
function Add-FileDetails {
param(
[Parameter(ValueFromPipeline=$true)]
$fileobject,
$hash = @{Artists = 13; Album = 14; Year = 15; Genre = 16; Title = 21; Length = 27; Bitrate = 28}
)
begin {
$shell = New-Object -COMObject Shell.Application
}
process {
if ($_.PSIsContainer -eq $false) {
$folder = Split-Path $fileobject.FullName
$file = Split-Path $fileobject.FullName -Leaf
$shellfolder = $shell.Namespace($folder)
$shellfile = $shellfolder.ParseName($file)
Write-Progress 'Adding Properties' $fileobject.FullName
$hash.Keys |
ForEach-Object {
$property = $_
$value = $shellfolder.GetDetailsOf($shellfile, $hash.$property)
if ($value -as [Double]) { $value = [Double]$value }
$fileobject | Add-Member NoteProperty "Extended_$property" $value -force
}
}
$fileobject
}
}
#Sample call:
#$music = [system.Environment]::GetFolderPath('MyMusic')
#$list = dir $music -Recurse | Add-FileDetails
#$list | Where-Object { $_.Extended_Year } | Sort-Object Extended_Year | Select-Object Name, Extended_Year, Extended_Album, Extended_Artists
$new2 | where {$_.Extended_Album} | select Name,Extended_Album | sort Extended_Album