如何使用 vb 脚本读取文件夹名称并查找特定单词?
例如:
文件夹名称 = 1234abc_Complete 如何使文本完整并存储为变量?
谢谢!
以下代码应按您的要求执行。
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).
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句