【发布时间】:2022-01-19 12:23:47
【问题描述】:
我正在尝试将所有文件夹(和所有文件)从一个文件夹复制到 Powershell 中的另一个文件夹,其中文件夹在文本文件中列出。我有一个脚本可以成功复制文件夹,但文件没有复制过来。
$file_list = Get-Content C:\Users\Desktop\temp\List.txt
$search_folder = "F:\Lists\Form601\Attachments\"
$destination_folder = "C:\Users\Desktop\601 Attachments 2021b"
foreach ($file in $file_list) {
$file_to_move = Get-ChildItem -Path $search_folder -Filter $file -Recurse -ErrorAction SilentlyContinue -Force | % { $_.FullName}
if ($file_to_move) {
Copy-Item $file_to_move $destination_folder
}
}
List.text 包含以下文件夹:
4017
4077
第4125章
【问题讨论】:
标签: powershell directory