Powershell loops

From wikinotes
Revision as of 03:20, 19 September 2018 by Will (talk | contribs) (→‎for loops)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

for loops

$array = 'a','b','c'
ForEach ($item in $array){
    # do stuff
}
foreach ($dir in (get-childitem -recurse -path . -filter "package.py)) {
    cd $dir.DirectoryName;
    rez-build -i;
}


foreach ($dir in (get-children -recurse -directory -filter "python")){
    if (!(get-childitem -recurse -path $dir -filter *.py)){
        echo $dir.directoryname
    }
}