Solved

RegExp help in VBscrpt or VB??

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

810 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