powershell - 使用 Powershell 递归复制文件和文件夹
问题描述
在 vbscript 中,我有一些代码可以使用 powershell 命令递归地复制文件和文件夹:
pCommand = "Copy-Item " & sourcePath & " " & destinationPath & " -Recurse -Force"
oShell.Run("powershell.exe -Command "" & " & pCommand & """"), 1, True
直到几个月前,这一直可以正常工作,但现在,我不确定原因,它不会复制所有文件,也不会保留所有结构。
例如,结构如下:
sourcePath\Report\Act1\Row0
sourcePath\Report\Act2\Row0
sourcePath\Report\Act3\Row0
...
sourcePath\Report\icons
sourcePath\Report\Resources\Checkpoints
在目标路径上,我最终得到:
destinationPath\Report\Act1\Row0
destinationPath\Report\Act2 (subfolder Row0 is not created)
destinationPath\Report\Act3 (subfolder Row0 is not created)
...
destinationPath\Report\icons => folder created but files within the folder are not copied
在执行期间,我不断看到这些类型的消息:
Copy-Item:目标文件“...\Report\Act3”是一个目录,而不是一个文件。
Powershell 有什么变化吗?我可以改用 objFSO.CopyFolder。它工作正常,但速度要慢得多。
谢谢
解决方案
推荐阅读
- c# - QueueTrigger 函数能否作为控制器进行响应
- python - 从脚本 Python/R 打开 plotly html 文件
- python - 指定代码覆盖数据文件的位置
- c++ - 父类的后代即使在声明为朋友后也无法访问其宿主类的私有成员数据字段
- c - 如何从 C git repo 生成 32 位 dll
- python - numpy.resize() 和 cv2.resize() 有什么区别?
- pandas - pandas 将不均匀的每小时数据重新采样到 1D 或 24h 箱中
- c# - 使用 JQuery 向 c# .net rest API 发出 POST 请求
- php - 一个月后如何自动删除文件?
- versioning - sphinx-versioning 显示分支而不是版本号