【发布时间】:2016-10-25 07:09:48
【问题描述】:
我是 ShellScript 的新手。这是我从提到的路径中删除“ONEWORD”的代码:如果我不在文件名中引入空格,它会按预期工作。但是如果文件名中有空格,则会抛出以下错误:
程序:
call:DoReplace "ONEWORD" "" "C:\Users\yeturukr\Desktop\Test\Dest\CMD COMET.txt" "C:\Users\yeturukr\Desktop\Test\Dest\CMD COMET.txt"
exit /b
:DoReplace
echo ^(Get-Content "%3" ^) ^| ForEach-Object { $_ -replace %1, %2 } ^| Set-Content %4 >Rep.ps1
Powershell.exe -executionpolicy ByPass -File Rep.ps1
if exist Rep.ps1 del Rep.ps1
echo Done
pause
错误:
Get-Content:无法将参数绑定到参数“路径”,因为它是 一个空的字符串。在 C:\Users\yeturukr\Desktop\Test\Rep.ps1:1 char:13 + (获取内容 降低,Microsoft.PowerShell.Commands.GetContentCommand
【问题讨论】:
标签: powershell batch-file cmd