我之前用批处理文件做过类似的事情
copy "%APPPATH%\*.exe" "%APPPATH%\*.exe.deploy"
所以我想将所有.exe
个文件复制到`.exe.deploy'
所以,如果我在目录中有以下内容:
a.exe
b.exe
c.foo
d.bar
我想最终:
a.exe
b.exe
c.foo
d.exe
a.exe.deploy
b.exe.deploy
d.exe.deploy
必须有一种优雅的方式来做到这一点。 BONUS 我还想指定多个扩展名(* .exe,* .txt,* .blob)并在一个命令中完成所有操作。
答案 0 :(得分:0)
使用PowerShell,您可以枚举要复制的文件并将结果通过管道传输到Copy-Item
cmdlet:
Get-ChildItem $env:APPPATH -Filter *.exe |
Copy-Item -Destination { $_.FullName + '.deploy' }
请注意-Filter
仅支持单个字符串。如果您想要传递多个扩展程序,则需要使用-Include
(但这只能与-Recurse
结合使用):
Get-ChildItem $env:APPPATH -Include *.exe,*.foo -Recurse |
Copy-Item -Destination { $_.FullName + '.deploy' }