Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: Renaming files with DTS using ActiveX script task

    Hi there,

    I have a DTS package that I want to use to copy a file from one directory to another, and then rename it. I'm doing this using a VB script within an ActiveX script task.

    The problem is I don't know exactly what the name of the file I need to copy will be. I do know it will be of the format t****1p**.xml

    I can copy all files of a particular file name format to another directory using this code within the script:

    Function Main()

    Set FSO = CreateObject("Scripting.FileSystemObject")
    FSO.copyfile "c:\test\t*1p*.xml", "c:\results\"
    Main = DTSTaskExecResult_Success

    End Function

    The problem here is that the file is copied with it's original file name, which is no good to me. If I try to specify the file name to copy to, ie:

    FSO.copyfile "c:\test\t*1p*.xml", "c:\results\data.xml" complains about an invalid path when I run the script.

    I've also tried this:

    Set FILE = FSO.GetFile("c:\test\t*p*.xml") = "data.xml"

    But it won't let me reference the file without specifying it's exact file name.

    Any help greatly appreciated!

    Ta in advance,

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I'm guessing, but I think you want to enumerate the source files using the Files object, then copy them one at a time (renaming as you go) using the CopyFile method.


  3. #3
    Join Date
    Mar 2004
    Thanks Pat that's done the trick!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts