Vbscript 使用VB脚本在文件夹名称中查找单词
如何使用vb脚本读取文件夹名称并查找特定单词 例如: 文件夹名称=1234abc\u完成 如何完成文本并将其存储为变量Vbscript 使用VB脚本在文件夹名称中查找单词,vbscript,directory,filenames,Vbscript,Directory,Filenames,如何使用vb脚本读取文件夹名称并查找特定单词 例如: 文件夹名称=1234abc\u完成 如何完成文本并将其存储为变量 谢谢大家! 以下代码应该按照您的要求执行 Option Explicit ' create a FileSystemObject Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject") ' Set a reference to the folder which contains the folders y
谢谢大家! 以下代码应该按照您的要求执行
Option Explicit
' create a FileSystemObject
Dim oFso : Set oFso = CreateObject("Scripting.FileSystemObject")
' Set a reference to the folder which contains the folders you want to look through
Dim oFolder : Set oFolder = oFso.GetFolder("PathToFolderInHere")
Dim oSubFolder, myVar
' loop through each subfolder
For Each oSubFolder in oFolder.SubFolders
' If the oSubFolder contains the word complete then set myVar and exit the loop
If InStr(1, oSubFolder.Name, "complete", vbTextCompare) > 0 Then
myVar = oSubFolder.Name
Exit For
End If
Next
' do whatever with myVar (the folder name you wanted in the variable).