Wrox Programmer Forums
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2006, 08:26 PM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB Script

I was wondering if someone had a quick answer - I have daily text files located on a file server and I wanted to change the name from something like:

aaa.bbb.ccc.ddd.txt

to

aaa_bbb_ccc_ddd.txt

Does anyone have some VB script of VB that could possibly do this??

 
Old March 12th, 2006, 08:06 PM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind - I found something that will work

-------------
Private Sub Command1_Click()
Dim MyFileNm(2) As String
Dim FSO

With Application.FileSearch
.LookIn = "C:\Documents and Settings\Owner\Desktop\Misc"
.SearchSubFolders = True
.FileName = "*.txt"

    If .Execute() > 0 Then

        For i = 1 To .FoundFiles.Count

           MyFileNm(1) = .FoundFiles(i)

           MyFileNm(2) = RReplace(.FoundFiles(i), ".", "_")
           MyFileNm(2) = RReplace(MyFileNm(2), "_txt", ".txt")

Set FSO = CreateObject("Scripting.FileSystemObject")

 If FSO.FileExists(MyFileNm(1)) Then
 FSO.copyfile MyFileNm(1), MyFileNm(2), True
 End If


        Next i
    Else
        MsgBox "There were no files found."
    End If


End With
End Sub

------------------

Public Function RReplace(strText As String, strFind As String, strReplace As String) As String
    RReplace = Replace(strText, strFind, strReplace)
End Function

Take Care






Similar Threads
Thread Thread Starter Forum Replies Last Post
VB script using xp_cmdshell getfunky SQL Server 2000 1 February 23rd, 2007 02:38 AM
Calling one VB.NET script from another kwilliams VB.NET 2 September 11th, 2006 06:26 AM
VB Script with Excel mateenmohd VB How-To 0 February 19th, 2005 06:33 AM
asp vb script error rsjaladi Classic ASP Databases 2 November 26th, 2004 10:46 AM
vb script is not working apry BOOK: Beginning ASP.NET 1.0 5 April 28th, 2004 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.