With below PowerShell script I am able to get Name, Size, DateCreated, Length of wav files from folder but I also want path of each files.
Please help me to update this code.
$folder= 'C:\Users\r.shishodia\Desktop\2-8-2018\web'
$com = (New-Object -ComObject Shell.Application).NameSpace($folder)
for ($i = 0; $i -lt 64; $i++) {
$name = $com.GetDetailsOf($com.Items, $i)
if ($name -eq 'Length') { $lengthattribute = $i}
}
$com.Items() | ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
Size = $com.GetDetailsOf($_, 1)
DateCreated = $com.GetDetailsOf($_, 4)
Length = $com.GetDetailsOf($_, $lengthattribute)
}
} | Export-Csv -Path C:\Users\r.shishodia\Desktop\report.csv -Encoding ascii -NoTypeInformation
Try something like this -
The
FullName
parameter will give you the path for each file.If we try your approach, then -
If you take a look at
$com.Items()
, you will see there is already aPath
property in it. So you can directly add that in your customPSObject
and export it viaCSV
.