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
Solved

RegExp help in VBscrpt or VB??

Posted on 2007-04-11
3
212 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 connector to SQL Server 2 37
passing a value with stream reader AFTER a ";" 3 74
VB6 ListBox Question 4 48
IF ELSE Statement in Excel Macro VBA 16 75
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

840 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