Solved

RegExp help in VBscrpt or VB??

Posted on 2007-04-11
3
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to With line 4 76
Internal Server Error on 1&1 Apache Server running PERL 3 71
perl syntax 3 36
"Failed to convert parameter value from a String to a Decimal." 4 33
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.…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

697 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