Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = Claus Brod: Regular recursion (25 Mar 2006) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="25"></a> ---+++ [[BlogOnSoftware%20060325][Regular recursion]] (25 Mar 2006) So I tried to come up with some simple code in <nop>VBscript which recursively searches a directory for file names of arbitrary patterns. This is what I got working: <pre> Sub recursiveSearch(dir, regex) for each file in dir.files if regex.Test(file.Name) Then WScript.Echo("File matches: " & file.Path) End if next for each folder in dir.SubFolders recursiveSearch folder, regex next End Sub startFolder="c:\temp" set folder=CreateObject("Scripting.FileSystemObject").GetFolder(startFolder) Set regex=new RegExp regex.Pattern = "^Foo\d{3}[0-9a-zA-Z]\.txt$" ' File name starts with 'Foo', followed by three digits, then either ' a digit or letter, and has a .txt extension. recursiveSearch folder, regex </pre> Somehow I've got a hunch that there may be an easier way to do this. Blogosphere, any ideas? %COMMENT{type="below" nonotify="on"}% --- %STOPINCLUDE%
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.2 |
>
|
r1.1
|
Total page history
|
Backlinks
You are here:
Blog
>
BlogOnSoftware20060325
r1.2 - 25 Mar 2006 - 13:07 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback