Click here to Skip to main content
15,888,046 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a folder inside this folder I have around 20 sub folders, each sub folder having .wav files and I have a power shell script using this script I am able to get data from a single folder, but I want to get data from all sub folders in one go when I click on main folder. Below is my power shell script. Please help me to modify my script.


What I have tried:

# Show an Open Folder Dialog and return the directory selected by the user.
function Read-FolderBrowserDialog([string]$Message, [string]$InitialDirectory, [switch]$NoNewFolderButton)
{
    $browseForFolderOptions = 0
    if ($NoNewFolderButton) { $browseForFolderOptions += 512 }

    $app = New-Object -ComObject Shell.Application
    $folder = $app.BrowseForFolder(0, $Message, $browseForFolderOptions, $InitialDirectory)
    if ($folder) { $selectedDirectory = $folder.Self.Path } else { $selectedDirectory = '' }
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($app) > $null
    return $selectedDirectory
}
$folder= Read-FolderBrowserDialog
$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
Path = $_.Path
Size = $com.GetDetailsOf($_, 1)
DateCreated = $com.GetDetailsOf($_, 4)
Length = $com.GetDetailsOf($_, $lengthattribute)
}
} |
Export-csv report.csv -notypeinformation
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900