Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move file with "file system object"

Status
Not open for further replies.

testare

Programmer
Jan 21, 2005
127
Hi,

I have a directory that containes two different file names

XXX_0900.xml
XXX_0901.xml
XXX_0902.xml
SSS_0900.xml
SSS_0901.xml
SSS_0902.xml

I would like to move all the XXX files to one directory and then move SSS files to another directory.
 
I have this code to move all files from a folder to another.

Code:
Private Function CountFiles(sFolderToCheck As String, sToFolder As String) As Long
Dim fs As FileSystemObject      'Microsoft Scripting Runtime (scrrun.dll)

    Set fs = New FileSystemObject
    'CountFiles = fs.GetFolder(sPath).Files.Count
    txtStatus.Text = "Flyttar"
    fs.MoveFile sFolderToCheck & "\*.*", sToFolder
    Set fs = Nothing

End Function

I dont know how to move to specific files.
I need help with that.

/Testare
 
Assuming that you've set the folder variables correctly:

fs.MoveFile sFolderToCheck & "\SSS*.*", sToFolder

will move the SSS files

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks for the help.
I will try that and get back to you if doesn't work.

/Testare
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top