Jump to content

xcopy with wild card for folders


todarsey

Recommended Posts

I have been trying to figure this one out and I have looked all over the place and can't find a solution to this.

Let's say I have several different folders in C:\images. The folders in this directory are as follows

SR23

SR23 2006

SR54

SR54 2006

US98

US98 2006

Is there a way to write a batch file with wild cards to only copy the folders that have the 2006 in the folder name using xcopy?

Link to comment
Share on other sites


I am not to good with the cmd promt but try this vbs script.

Save As Copy2006Folders.vbs

Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
'-> This Makes The Folder Where The Script Is Located The Parent Folder
Dim Col :Set Col = Fso.GetFolder(".")
'-> Example Using A Full Path
' Dim Col :Set Col = Fso.GetFolder("C:\TheFolder")
Dim Obj, CopyTo
'-> Place The Path To Where You Want To Copy To Here.
CopyTo = "PATH_TO_COPY_TO"
For Each Obj In Col.SubFolders
If InStr(Obj.Path,"2006") Then
Fso.CopyFolder Obj.Path, CopyTo, true
End If
Next

Place this script in the folder you want to do the copy or you can add a full path.

'-> This Makes The Folder Where The Script Is Located The Parent Folder
Dim Col :Set Col = Fso.GetFolder(".")
'-> Example Using A Full Path
' Dim Col :Set Col = Fso.GetFolder("C:\TheFolder")

Then fill in the CopyTo varible

CopyTo = "PATH_TO_COPY_TO"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...