ForEach-Object
CautionProcess each item
... | ForEach-Object {処理}
Applies a block per item (short form %). Bulk renames, repeated ops; -Parallel on PS7.
Examples
gci *.log | % { Rename-Item $_ ($_.BaseName + '.bak') }Bulk-rename extensions
Syntax
<cmd> | ForEach-Object {$_ ...} / % {...}
Before you run it
Preview targets with gci before bulk changes.
Related commands
- Where-ObjectFilter objects
- xargsBuild & run command lines
The same reference, with no signal at all
Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.
Get it free on the App Store