首页 > 解决方案 > 有没有更快的方法通过 PowerShell 脚本移动图片

问题描述

如果它们在我的 txt 文件中列出,我想将所有图片从多个文件夹移动到一个目标文件夹。

该脚本有效,但 txt 文件中有大约 81k 图片和 450k 名称(例如samlpe-green-bigpic-detail-3.jpg),这该死的慢。

有没有办法编写脚本,所以它工作得更快?

$qpath     = "c:\sample\picz\"
$Loggit    = "c:\sample\pic_move.log"
$txtZeileU = "c:\sample\names.txt"
$d_pic     = "C:\sample\moved_picz"

$arrZeileU = Get-Content -Path $txtZeileU
foreach ($Zeile in $arrZeileU) {
    Get-ChildItem -Path $qpath -Recurse |
        where {$_.Name –eq $Zeile} |
        Move-Item -Destination $d_pic -Verbose -Force *>&1 |
        Out-File -FilePath $Loggit -Append
}

标签: performancepowershell

解决方案


推荐阅读