Solved

RegExp help in VBscrpt or VB??

Posted on 2007-04-11
3
206 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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
Hmm - was something missing?
I'm curious what I could have added for this to be considered an "A" grade?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now