问题标签 [delay-bind]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1454 浏览

powershell - 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.

This example shows how to use the Replace operator to rename multiple files, even though the NewName parameter does not accept wildcard characters.

This command renames all of the .txt files in the current directory to .log.

The command uses the Get-ChildItem cmdlet to get all of the files in the current folder that have a .txt file name extension. Then, it uses the pipeline operator (|) to send those files to Rename-Item .

The value of NewName is a script block that runs before the value is submitted to the NewName parameter.

Note the last sentence:

The value of NewName is a script block that runs before the value is submitted to the NewName parameter.

Actually NewName is a string:

So does that means I can always use a script block when the required parameter type is a string?

0 投票
3 回答
143 浏览

powershell - 根据公式自动批量重命名文件,包括使用 Powershell 的父文件夹名称

如何使用以下代码在 powershell 中批量重命名文件:

其中PPPPPP是包含这些文件的父文件夹的名称。

预期输出:

文件位于 C:\USER\MAIN\BLABLABLA\PPPPPPP 文件夹中。