Note that there are some explanatory texts on larger screens.

plurals
  1. POVBScript storing collection resulting from regex matching a file collection into array
    primarykey
    data
    text
    <p>I want to access RegEx results after I am done moving files with this script. (For example: I want to later send the names of files that matched regex pattern to my E-mail)</p> <p>Problem is: Can't use "objFile.Name" outside of the initial file moving loop that I get during regex. This should have been possible using the "Execute" method for RegEx, but unfortunately I can't get it to work on a collection resulting from "GetFolder().Files", it works for me only on single strings.</p> <p>Only Test method worked for me initially, and it works OK for initial file moving, but then I get runtime errors when I cannot access the "objFile" object later.</p> <p>My latest attempt to try to write resulting matches into array also don't work, error is:</p> <p><strong>Line 26, 3</strong></p> <p><strong>Object doesn't support this property or method:</strong></p> <p><em><strong></em>'SubMatches'</strong></p> <p>Here's the latest attempt at getting this code to work:</p> <pre><code>Set objFS = CreateObject("Scripting.FileSystemObject") strDumpStorageDir = "C:\" strShareDirectory = "E:\" Set objFolder = objFS.GetFolder(strShareDirectory) Set colFiles = objFolder.Files Set re = New RegExp re.Global = True re.IgnoreCase = False re.Pattern = "fs" Dim matches() Dim i: i = 0 For Each objFile in colFiles bMatch = re.Test(objFile.Name) If bMatch Then objFS.MoveFile strShareDirectory &amp; objFile.Name , strDumpStorageDir End If ReDim preserve matches(i) Matches(i) = objFile.SubMatches(0) i = (i + 1) Next For i = 0 to uBound(Matches) wscript.echo Matches(i) Next WScript.Quit </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload