Delay-binding is a PowerShell technique for passing script blocks (snippets of code) in lieu of regular arguments for dynamically deriving argument values from each input object passed through the pipeline.
Questions tagged [delay-bind]
3 questions
4
votes
3 answers
For PowerShell cmdlets, can I always pass a script block to a string parameter?
I'm looking at the documentation of PowerShell's Rename-Item cmdlet and there is an example like this.
Get-ChildItem *.txt | Rename-Item -NewName { $_.name -Replace '\.txt','.log' }
This example shows how to use the Replace operator to rename…

Just a learner
- 26,690
- 50
- 155
- 234
1
vote
2 answers
Using Powershell to change filenames
When did changing filenames become so complicated??
All I want to do is add '_a' to a directory of files (with no extension)
The following does not work:
Rename-Item -newname { $_BaseName + '_a' } -whatif
Rename-Item : Cannot evaluate parameter…

Rob Waibel Jr
- 25
- 3
1
vote
3 answers
Automatically batch renaming files according to a formula including parent folder name using Powershell
How can I batch rename files in powershell using the following code:
$nr=1;Get-ChildItem -Filter *.jpg |
Rename-Item -Newname {"PPPPPPP_{0:d3}.jpg" -f $global:nr++}
where PPPPPPP is the name of parent folder containing these files.
Expected…

Fredes
- 31
- 1
- 5