首页 > 解决方案 > PowerShell脚本检查文件夹中的文件

问题描述

需要你的帮助我有点卡住了我需要创建一个powershell脚本,它从csv文件中获取id号,然后检查一个特定文件夹(和所有子文件夹)中所有文件名中存在该id号的文件,然后将所有文件移动到我选择的文件夹中

提前感谢

标签: powershellfiledirectory

解决方案


我希望它会帮助你。

$fileNames = gc Your\csv\path\MyCSVFile.csv

    foreach($file in $fileNames)
    {
        Get-ChildItem -Path your\source\folder\path\SourceFolder -Recurse | Where-Object {$_.Name -eq $file} |  Move-Item -Destination your\dest\folder\path\DestinationFolder
    }

推荐阅读