dbTalk Databases Forums  

SQL DTS Traverse subfolders, copy files, run package to import.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SQL DTS Traverse subfolders, copy files, run package to import. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DragonLancer1970
 
Posts: n/a

Default SQL DTS Traverse subfolders, copy files, run package to import. - 01-11-2005 , 09:51 PM






Greetings,

I hope someone might be able to point me in the right direction on this
one. I am new to this so....... here goes.

I have a DTS ActiveX script that I would like to traverse through a
series of subfolders and copy selected files, rename them and drop them
in another directory. Secondly, I need to be able to run a DTS package
against the files that were copied to the holding tank. The DTS
package imports the contents of the files into a series of tables for
further processing. Then the process would move to the next subfolder
and repeat the process, and again, and again, until all folders haver
been processed.

I can't seem to find a solution, any ideas?

**************************************************
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\fileserver\f$\UserDBs")
For Each Folder In f.Subfolders
path = "\\fileserver\f$\UserDBs\" & Folder.Name & "\"

Set objContacts = fso.GetFile(path & "builder.dbf")
objContacts.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderDBF.dbf", 1

Set objActivity = fso.GetFile(path & "builder.adb")
objActivity.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderADB.dbf", 1

Set objListTable = fso.GetFile(path & "builder.ddb")
objListTable.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderDDB.dbf", 1

Set objSales = fso.GetFile(path & "builder.sdb")
objSales.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderSDB.dbf", 1

Set package = CreateObject("DTS.Package")

package.LoadFromSQLServer "SQLRPTS", "", "","256",,,,"FillSalesOppsTMP"
package.Execute

package.Uninitialize()
Set package = nothing

Main = DTSTaskExecResult_Success
Next

************************************************** *********
Sincerely,

DragonLancer1970
Dallas, TX


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: SQL DTS Traverse subfolders, copy files, run package to import. - 01-12-2005 , 12:35 AM






You probably need a combination of these two articles

Looping, Importing and Archiving
(http://www.sqldts.com/default.aspx?246)

and

Find an Access Database (from anywhere on the file system)
(http://www.sqldts.com/default.aspx?248)

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


"DragonLancer1970" <joliver (AT) pestdefense (DOT) com> wrote

Quote:
Greetings,

I hope someone might be able to point me in the right direction on this
one. I am new to this so....... here goes.

I have a DTS ActiveX script that I would like to traverse through a
series of subfolders and copy selected files, rename them and drop them
in another directory. Secondly, I need to be able to run a DTS package
against the files that were copied to the holding tank. The DTS
package imports the contents of the files into a series of tables for
further processing. Then the process would move to the next subfolder
and repeat the process, and again, and again, until all folders haver
been processed.

I can't seem to find a solution, any ideas?

**************************************************
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("\\fileserver\f$\UserDBs")
For Each Folder In f.Subfolders
path = "\\fileserver\f$\UserDBs\" & Folder.Name & "\"

Set objContacts = fso.GetFile(path & "builder.dbf")
objContacts.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderDBF.dbf", 1

Set objActivity = fso.GetFile(path & "builder.adb")
objActivity.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderADB.dbf", 1

Set objListTable = fso.GetFile(path & "builder.ddb")
objListTable.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderDDB.dbf", 1

Set objSales = fso.GetFile(path & "builder.sdb")
objSales.Copy "\\fileserver\f$\holdingtank\" & FolderName &
"builderSDB.dbf", 1

Set package = CreateObject("DTS.Package")

package.LoadFromSQLServer "SQLRPTS", "", "","256",,,,"FillSalesOppsTMP"
package.Execute

package.Uninitialize()
Set package = nothing

Main = DTSTaskExecResult_Success
Next

************************************************** *********
Sincerely,

DragonLancer1970
Dallas, TX




Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.