[英]Copy files without recreating subdirectories using Powershell
The solution here works for me if the command is executed at a command prompt: 如果命令在命令提示符下执行,这里的解决方案适用于我:
Copy files without recreating subdirectories 复制文件而不重新创建子目录
However, I get an error if the command is in a batch file: 但是,如果命令在批处理文件中,则会出错:
"The following usage of the path operator in batch-parameter substitution is invalid %~nf" “批处理参数替换中路径运算符的以下用法无效%~nf”
How do you code this in Powershell? 你如何在Powershell中编写代码?
Replace any %
with %%
in a bat file. 在bat文件中用%%
替换任何%
。
So %~nf
becomes %%~nf
所以%~nf
变成了%%~nf
Powershell equivalent: Powershell等效:
gci -r .\test | ?{-not $_.PsIsContainer} | copy-item -Destination .\test2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.