我正在尝试执行以下操作:
Rename-Item c:\misc\*.xml *.tmp
Run Code Online (Sandbox Code Playgroud)
我基本上想要更改目录中每个文件的扩展名.tmp而不是.xml.我似乎无法在PowerShell中找到一种直接的方法.
我正在尝试重命名我的应用程序中的许多文件,并且需要能够在应用程序根目录中通过git(即git mv%filenamematch %% replacement%)在所有子目录中进行重命名,只替换匹配的文本.我对bash脚本没有好处.
更新:如果还重命名匹配的目录也会很好!
要更改位于以下位置的文件的扩展名:C:\Users\mohit singh\Desktop\spotlight,我在 PowerShell 中键入以下命令
C:\Users\mohit singh\Desktop\spotlight> ren *.* *.jpg
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
ren : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path"
argument and run the operation again.
At line:1 char:1
+ ren *.* *.jpg
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Rename-Item], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand
Run Code Online (Sandbox Code Playgroud)