PowerShell将文件列表复制到文件夹列表

时间:2016-11-29 14:21:13

标签: file powershell foreach copy

我需要将文件列表复制到不同目标文件夹的列表中。我正在使用的当前脚本适用于一个目标。如何让它在多个目的地工作?

# source and destionation directory
$src_dir = "C:\test\"
$dst_dir = "\\remote_PC\c$\test"

# list of files from source directory that I want to copy to destination folder
# unconditionally
$file_list = "*.txt", 
             "*.jpg",
             "*.doc"

# Copy each file unconditionally (regardless of whether or not the file is there
foreach ($file in $file_list)
{
  Copy-Item $src_dir$file $dst_dir
}

0 个答案:

没有答案