Issue in power shell script to get audio file data from folder having subfolders.

Hi All,

I am new to power shell,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. Below is my power shell script. How to make this script to loop through each folder.
Below is my script which I have try.

# 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 {
Name = $_.Name
Path = $_.Path
Size = $com.GetDetailsOf($_, 1)
DateCreated = $com.GetDetailsOf($_, 4)
Length = $com.GetDetailsOf($_, $lengthattribute)
} |
Export-csv report.csv -notypeinformation

  • You need to use the -recurse parameter

    This is all documented in the built-in PoSH help files with examples:

        # Get parameters, examples, full and Online help for a cmdlet or function

        (Get-Command -Name Get-ChildItem).Parameters
        Get-help -Name Get-ChildItem -Examples
        Get-help -Name Get-ChildItem -Full
        Get-help -Name Get-ChildItem -Online

    BTW, this is way overkill for what your use case is.

    Since you say you are new, don't struggle at this or cause yourself undue stress. Take a few no cost online courses so you have a full baseline as you take off on my PoSH adventures.

    Learning Resources

        Learn PowerShell: Microsoft Virtual Academy – Getting Started with Microsoft


        Microsoft Channe9


        Windows PowerShell Survival Guide


        And start with lots of examples.

        Looking at the .ps* files already on your system. There are bunches of them     located here:


        Just make a copy of that and open in the PowerShell_ISE.exe and review them.
        Heck even in the ISE just hit CRTL+J to see a list of prebuilt snippets to     review and understand.