1
如果命令在命令提示符下执行此解决方案的工作对我来说子目录复制文件:无需重新创建使用PowerShell
Copy files without recreating subdirectories
不过,我得到一个错误,如果该命令是在一个批处理文件:
“在批参数替代路径运算符的以下用法无效%〜NF”
如何在PowerShell代码呢?
如果命令在命令提示符下执行此解决方案的工作对我来说子目录复制文件:无需重新创建使用PowerShell
Copy files without recreating subdirectories
不过,我得到一个错误,如果该命令是在一个批处理文件:
“在批参数替代路径运算符的以下用法无效%〜NF”
如何在PowerShell代码呢?
将任何%
替换为bat文件中的%%
。
所以%~nf
成为%%~nf
PowerShell的等价:
gci -r .\test | ?{-not $_.PsIsContainer} | copy-item -Destination .\test2
谢谢!我怎样才能改变这些命令来接受起始目录作为参数? – user1062718
在PowerShell中?在脚本的顶部使用'param($ source)'并在你想要的地方使用'$ source'。阅读Powershell参数 – manojlds