简体   繁体   中英

downloading multiple files to multiple folder using ssis from sftp

I am trying to download multiple files that are located in multiple folders from an FTP site into multiple folders on a specific drive using FTP task and script task in SSIS. I am not downloading the files into one specific folder. I have looked everywhere and I could not find any good information. Any help is much appreciated. Thanks.

If you're not required to use a script task for some reason, then here is what you want to do:

  1. Create a Foreach Loop Container
  2. Under the Collection tab, Folder field, browse to the folder that contains all of the subfolders that you are pulling files from off your source FTP. (This is making the assumption that such a folder exists, which hopefully it does or you can create one)
  3. Check the Traverse Subfolders box, and choose Fully Qualified
  4. Under the Variable Mappings tab, create a variable @FileNameWithPath or whatever you want to call it. Index default is fine.
  5. Create a package variable called FileName
  6. Set the expression of FileName to this, which will remove the path:

RIGHT(@[User::FileNameWithPath], FINDSTRING(REVERSE(@[User::FileNameWithPath]), "\\\\", 1 )-1)

  1. Create a package variable called FilePrefix
  2. Make an expression to pull the prefix out of the FileName . It will be this, if you're grabbing everything before the first underscore:

LEFT( @[User::FileName],FINDSTRING(((DT_WSTR, 150) @[User::FileName] ), "_", 1)-1)

  1. Create another variable called DestinationFolder .
  2. Use the FilePrefix variable you just created to build the expression for DestinationFolder . It will be this:

"\\\\Your destination FTP\\" + @[User::FilePrefix]

  1. Within your Foreach Loop Container, add a File System Task
  2. Set the File System Task to a move or copy, whatever you need, with a Source Variable of FileNameWithPath , and a destination variable of DestinationFolder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM