如果使用Get-ChildItem参数和排除项更新,则复制项目

时间:2018-01-23 14:12:27

标签: powershell get-childitem copy-item

我有一个脚本可以监控文件夹,并将符合参数的文件复制到一个单独的位置并重命名。我有GCI$source已排除的$destination排除文件,但如果$source文件有更新的时间戳,则希望跳过排除。即如果$source中存在较新版本的文件,请将其复制到$destination,否则跳过它。

我现在有什么:

foreach ($file in $files) {
    GCI -Path $output -Filter "*$($file.Files)*" -Include '*.jpg' -Exclude $alreadyMoved.Name -Recurse |
        Copy-Item -Destination $destination -PassThru |
        Rename-Item -NewName {$_.Name -replace 'PC_...','PC_620'} 
}

我不确定最有效的方法,但我需要它才能顺利运行并按正确的顺序排序/过滤,以尽快使GCI

0 个答案:

没有答案
相关问题