Currently I am using this line to collect all files in a certain path (and beyond)
$files = Get-ChildItem -Path $loc -Recurse | ? { !$_.PSIsContainer }
however now ive been asking to generate this list while exclude (for example) all “docx” and “xlsx” files… and folders named “scripts” and their content
I want to read in these file extensions and directory names from a txt file into an array and simply use that array.
Also would speed is important as the functions I will be performing on these files take long enough, I dont need this process slowing down my script 10 full (a bit is okay)
Thanks so much for any inputs
FAILED ATTEMPT:
gi -path H:\* -exclude $xfolders | gci -recurse -exclude $xfiles | where-object { -not $_.PSIsContainer }
I think this works but only does the folder exclusion at the root of the H:\ drive
Something like this? I’m comparing the realative path only(path from $loc) in case
$locincludes one of the foldernames to ignore.Multiple folders(this got ugly):