[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

RegExp help in VBscrpt or VB??

Posted on 2007-04-11
3
Medium Priority
?
219 Views
Last Modified: 2007-12-19
I need help RegExp in vbscript.

I am trying to find files in subfolders and copy them to a target folder.
Here are my set up:
Root folder: C:\projects\taskers\names\
there are multiple subfolders in names folder
C:\projects\taskers\names\xx2x
C:\projects\taskers\names\xxx4
...
I am looking for any document's name starting with '((' and copy it when it got found to another folder.
target folder: C:\projects\taskers\Target\

I can handle looking for files and subfolders.
But I need help with the regexp.
The file I am looking for has this naming syntax, ((multiple words))multiple words.doc
Basically I want to match anything that starts with ((.
Thanks much.
0
Comment
Question by:dkim18
  • 3
3 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18890903
Why not use simply

For Each file in Folder.Files
  If Left(file.name,2)="((" Then
  'copy file...
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 1500 total points
ID: 18890917
Something like...

Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objFolder: Set objFolder=objFSO.GetFolder("C:\Projects\taskers\names\")
strDestination="C:\FolderName\"
ScanFolder(objFolder)

Sub ScanFolder(strSource)
  ScanFiles strSource
  For Each fld In strSource.SubFolders
    ScanFolder fld
  Next
End Sub

Sub ScanFiles(strSrc)
  For Each file In strSrc.Files
    If Left(file.name,2)="((" Then objFSO.CopyFile file.path, strDestination
  End If
  Next
End Sub
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18910170
Hmm - was something missing?
I'm curious what I could have added for this to be considered an "A" grade?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question