If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Renaming files with DTS using ActiveX script task

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-26-04, 12:32
dancoupar dancoupar is offline
Registered User
 
Join Date: Mar 2004
Posts: 5
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"

...it complains about an invalid path when I run the script.

I've also tried this:

Set FILE = FSO.GetFile("c:\test\t*p*.xml")
FILE.name = "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,
Dan.
Reply With Quote
  #2 (permalink)  
Old 03-26-04, 14:50
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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.

-PatP
Reply With Quote
  #3 (permalink)  
Old 03-29-04, 05:15
dancoupar dancoupar is offline
Registered User
 
Join Date: Mar 2004
Posts: 5
Thanks Pat that's done the trick!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On