在VB脚本

时间:2017-03-06 13:14:08

标签: vbscript

我需要您的帮助,如何排除给定文件夹的特定国家/地区文件名。

    DIM datasource

    datasource = objRs.Fields(0).Value
    Region =  replace(objRs.Fields(1).Value," ","_",1,-1,0)
    CountryCode = Region &"_"& serialNumber1
    '-----------------------------------------------------------------
    'Region subfolder creation              
    packageCountryDataPath = outputfolder&"\"& Region
    If  Not fso.FolderExists(packageCountryDataPath) Then
        fso.CreateFolder(packageCountryDataPath)
        WScript.Echo "Regions Folders created: " & Region & ""
    End If

我想只排除像UN& amp;这样的特定国家/地区文件夹。嘛。我不想生成这些文件夹

Do Until objRs.EOF
    datasource = objRs.Fields(0).Value
    WScript.Echo datasource
    Region =  replace(objRs.Fields(1).Value," ","_",1,-1,0)
    CountryCode = Region &"_"& serialNumber1
    '-----------------------------------------------------------------
    'Region subfolder creation              
    packageCountryDataPath = outputfolder&"\"& Region
    If  Not fso.FolderExists(packageCountryDataPath) Then
        fso.CreateFolder(packageCountryDataPath)
        WScript.Echo "Regions Folders created: " & Region & ""
    End If
    WScript.Echo "Regions Folders created: " & packageCountryDataPath & ""

    Set folder = fso.GetFolder(Inputfile)
    Set files = folder.Files
    For each item In files
      If Instr(item.Path,".xml") <> 0 then  
         logfilename =item.Name
        logfilename= replace(logfilename,".xml","",1,-1,0)  
          returnValue = exportDatasource(item.Path,logfolder&"\"& logfilename &".log", datasource, CountryCode, DateTime, utilsfolder, packageCountryDataPath, dbDataSource, dbLogin, dbPassword)                    
        If returnValue = 0 Then
            'WScript.Echo "Datasource " & Region & " processed"
        Else
            WScript.Echo "Error while processing Datasource " & Region
            Exit Do
        End If
      End If

请告诉我们如何做到这一点。

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

您的选择

  1. 在获取记录集的SQL语句中使用Where子句。
  2. 使用InStr(&#34; | aa | bb | ... | zz |&#34;,&#34; |&#34;&amp; Region&amp;&#34; |&#34;)在白名单或黑名单上的国家/地区代码(???)。
  3. 使用词典和d.Exists(Region)来确定Region是否是此类列表的元素。
  4. cf here