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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load Multiple Files from Source to Respective Multiple Folders (SSIS) 1

Status
Not open for further replies.

BTrees

IS-IT--Management
Aug 12, 2006
45
CA
Hi All,

In SSIS or SQL-stored procedure, I need to load multiple files to multiple folders with respect to file names
I have a scenario
Source folder = “Data Source Folder”

Files in source folders
Customer_datafile_data.csv
Customer_Branch_data.csv
Customer_City_data.csv
Employee_datafile_Dec2020.csv
Employee_Info_Dec2020.csv
Products_Information.csv

Destination Folders =
Customer
Employee
Products

Files destination as
“Customer_datafile.csv” LOADS IN “ Customer”
"Customer_Branch_data.csv" LOADS IN “ Customer”
"Customer_City_data.csv” LOADS IN “ Customer”

“Employee_datafile_Dec2020.csv” LOADS IN “Employee”
Employee_Info_Dec2020.csv ” LOADS IN “Employee”

“Products_Information.csv” LOADS IN “Products”

No. of files for one destination could be as many. No. of folders may be as many (not 3 it could be 4 or 5 )
One thing that I can control is the prefix of file is matched with folder name in which it has to load
Please help me in some good solution. Thanks









 
not sure if you are giving all info required for us to point you in the right direction.

regardless of that if this is just a move files from one folder to another do not use SSIS at all, and rather use powershell.

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Thanks Frederico for the response.
I think I have provided all the information required in terms of folders and file structure.
My requirement is to move multiple files from the mentioned source folder to multiple target folder based on their names. e.g files starting with 'Customer' should to to Customer folder and so on.

As you have mentioned, not necessarily SSIS/foreach loop container etc., I could try powershell as well but I am not expert. If I could get help I will try out. Thanks.
If you have any question please let me know. Thanks
 
this is the type of question that a google search gives back lots of results - no need to be an expert.

create a file (config.csv) with following content - adapt folder as required
Pattern,DestinationFolder
customer_,c:\temp2\Customer
employee_,c:\temp2\employee
products_,c:\temp2\products

then create a powershell script like this - how you execute it you can google or read the manual

$inputfolder = "c:\temp2\input"
$config = Import-Csv C:\temp2\config.csv
foreach ($entry in $config)
{
Get-ChildItem -Path $inputfolder| where {$_.name -like "$($entry.Pattern)*.csv"}|Move-Item -Destination $entry.DestinationFolder -Force
}

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Thanks you Frederico. I tried it according to my folders and it worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top