bluebunny72 icon

recurse directory

bluebunny72 | PRO | 03/22/16 10:33:37 PM UTC | 0 ⭐ | 471 👁️ | Never ⏰ | []
PowerShell |

450 B

|

None

|

0 👍

/

0 👎

$filePath = "D:\dwg";
$dwg = @(Get-ChildItem -Recurse -Path $filePath | Where-Object { $_.Extension -eq ".dwg" });
if ($dwg.length -eq 0) {
 write-host "no files found" -foregroundcolor "Red";
}
else {
  foreach ($file in $dwg) {    
    $name = $file.name;
    $directory = $file.DirectoryName;
    write-host "$directory\$name" -foregroundcolor "Red";
    write-output "$directory\$name" | out-file -append -filepath D:\output.txt -encoding ASCII
    }
}

Comments