Advertisement
bluebunny72

recurse directory

Mar 22nd, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $filePath = "D:\dwg";
  2. $dwg = @(Get-ChildItem -Recurse -Path $filePath | Where-Object { $_.Extension -eq ".dwg" });
  3. if ($dwg.length -eq 0) {
  4.  write-host "no files found" -foregroundcolor "Red";
  5. }
  6. else {
  7.   foreach ($file in $dwg) {    
  8.     $name = $file.name;
  9.     $directory = $file.DirectoryName;
  10.     write-host "$directory\$name" -foregroundcolor "Red";
  11.     write-output "$directory\$name" | out-file -append -filepath D:\output.txt -encoding ASCII
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement