title: Powershell getting foldername like, and get the first subdirectory
body: <p>I already have this script for getting the files from all subdirectories
  But I can't control the depthlevel of getting subdirectories.
  What I mean is, I have multiple subdirectories in my path. For example.
  C:\SCRIPTS\testing\testfiles\rawfiles and under rawfiles, there's subdirectories</p>
  
  <ol>
  <li>stuck_test</li>
  <li>raw_testfiles1-->stuck_test</li>
  <li>raw_testfiles2-->stuck_test</li>
  <li>raw_testfiles3-->stuck_test</li>
  <li>raw_testfiels4-->stuck_test</li>
  </ol>
  
  <p>And what I want to do is to get the stuck_test not inside at raw_testfiles1 directory. But I don't want to specify the path. Its like I want to limit the -recurse.
  Thanks in advance.
  I'm really stuck here.</p>
  
  <pre><code> cls
  
      $folderName = "stuck_test" 
      $pathtest = "C:\SCRIPTS\testing\testfiles\rawfiles"
  
      $gettest = Get-ChildItem -path $pathtest -filter $foldername -recurse| Select-Object -Expand FullName
  
      $path1 = $gettest
  
      $Allfiles = Get-Childitem -Path $path1 -recurse| Where {!$_.PSIsContainer}| Select-Object Fullname
  
      foreach ($file in $Allfiles)
          {       
             $file1 = $file.Fullname
             $foldername = Get-ChildItem -Path $file.Fullname
             $input = $foldername.Directoryname
             $Mothername = Get-Item -Path $input
             $output = $Mothername.Parent.Fullname
             $output = "$output\processed"
             Write-Host "The Filename: $file1"
             Write-Host "The FolderName: $input"
  
             $Getbase = (Get-Item $file1).BaseName
             Write-Host $Getbase
  
             "$file1" | Out-File -FilePath "C:\SCRIPTS\tester\LIST\stuck_files_list.txt" -Append
  
  
          }
  </code></pre>