【发布时间】:2016-05-06 23:25:00
【问题描述】:
对于通配符标志,我可以说只复制名称中同时包含sp 和MPK 的文件吗?
$source = "D:\scripts\watcher\2015-007"
$destination = "K:\public\scripts\watcher\2015-006"
$sourceOptions = "*sp* *MPK* /COPYALL"
$sourceOptions2 = "*sp* /COPYALL"
$copyOptions = "/Z /SECFIX /XX /MT[:32] /LOG+:$destination\logs\RoboLog.txt /V /R:5 /W:1"
New-Item K:\public\scripts\watcher\2015-006\logs -ErrorAction SilentlyContinue -type directory
Start-Process robocopy -ArgumentList "$source $destination $sourceOptions $copyOptions" -wait -NoNewWindow -PassThru
我正在使用 PowerShell 运行 robocopy,我创建了一些变量并将它们按正确的顺序放置,以便它们与 robocopy 一起使用。
在变量$sourceOptions 中,我为robocopy 定义了一些通配符。
文件名中带有sp 或MPK 的任何内容都将移至目标位置。
对于通配符标志,我可以说只复制名称中同时包含sp 和MPK 的文件吗?
【问题讨论】:
-
不要太努力。 This article 提供了一些关于如何正确地将命令行参数传递给 PowerShell 中的程序的帮助。
标签: powershell conditional wildcard robocopy