开发者

how to iterate over files with powershell?

I want to iterate over files in a folder using po开发者_如何学Gowershell script;


Get-ChildItem | ForEach-Object { <# do what you need to do #> }

or shorter:

gci | % { <# ... #> }

or if you want an explicit looping construct:

foreach ($file in Get-ChildItem) {
    # ...
}

Note however, that foreach will only run once all output from Get-ChildItem is collected. In my opinion most Powershell code should use the pipeline as much as possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜