【问题标题】:Powershell, Excel search for folder [closed]Powershell,Excel搜索文件夹[关闭]
【发布时间】:2021-11-10 21:04:58
【问题描述】:

我有一个 Excel 列表,其中包含“A”列中的文件夹路径。我想检查这些路径/文件夹是否存在。如果存在,则在“B”列中输入“OK”,如果不存在,则在“B”列中输入“error”。

【问题讨论】:

    标签: excel powershell


    【解决方案1】:

    将您的 Excel 保存为 CSV 文件

    然后在 PowerShell 中执行:

    $csv = Import-Csv -Path 'X:\theFile.csv' -Header 'path','exists' -UseCulture
    foreach ($item in $csv) {
        $item.exists = if (Test-Path -Path $item.path) {'OK'} else {'error'}
    }
    # re-save the file
    $csv | Export-Csv -Path 'X:\theFile.csv' -UseCulture -NoTypeInformation
    

    最后双击该文件以在 Excel 中打开

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      相关资源
      最近更新 更多