本文介绍了如何使用PowerShell映射文件夹名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想映射一个文件夹以下载并解压缩该文件夹.这就是我需要下载文件夹的方式.

I want to mapping an a folder to download and extract the folder.This is the way I need to download the folder.

DownloadF.exe --net 10.0.0.1 --user XX --id 00 --ver A00X-F1A >> result.txt

我有26个要映射的版本,即

I have 26 version to mapping, which are

A00X-F1A ... A00X-F1Z (the last character is A - Z)

如果 result.txt 包含此字符串"folder available".这表示版本正确,然后停止循环播放或检查其他版本.

If the result.txt contain of this string "folder available". It means the version is correct, then stop the looping or checking other version.

我必须检查从 A00X-F1Z,A00X-F1Y,A00X-F1X,... A00X-F1A 开始的版本.任何人都可以给我个主意.

I must check the version start from A00X-F1Z, A00X-F1Y, A00X-F1X, ... A00X-F1A.Anyone can give me idea please.

##Updated
$Version = "A00X-F1"
$List_Ver = 90..65 | ForEach-Object{"$Version" + [char]$_}
$n = 0
foreach ($list in $List_Ver){
    while ($Result -notcontains "Folder Available")
    {
        $n++
        & DownloadF.exe --net 10.0.0.1 --user XX --id 00 --ver $list >> $list.txt"
        Start-Sleep -s 3
        $Result = Get-Content -path .\$list.txt
    }
}

推荐答案

这是我根据收集的内容进行测试的结果,

This is what I tested with what I gather you are looking for,

示例result.txt

A00X-F1Z
A00X-F1Y
A00X-F1X
A00X-F1W
A00X-F1V
A00X-F1U
A00X-F1T
A00X-F1S
A00X-F1R
A00X-F1Q

要使用的代码

$Version = "A00X-F1"
$List_Ver = 90..65 | ForEach-Object{"$Version" + [char]$_}
$result = Get-Content C:\temp\result.txt
$string = "Folder Not Available"
foreach($list in $List_Ver) {
DownloadF.exe --net 10.0.0.1 --user XX --id 00 --ver $list >> result.txt
  if ($result -like $string ) {
    $n = 0
    while ($result -like $string)
    {
      $n++

     Write-Host "Not Found"
     Break
}
  }
  else {
     Write-Host "Found"
     Break
  }
}

这篇关于如何使用PowerShell映射文件夹名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 23:08