Topic "Move remote files in a loop"

Author Message
ahd262

Guest


Hi
on a daily basis i receive a number of zipped files in a remote folder
The number and the name of these files changed each day and they aren t known in advance
I need to move each of one into an appropriate folder

I m using SSIS and would like to know how in a loop to be able to read them and to move them

Thx for your help
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24998
Location: Prague, Czechia
Do you want to iterate a list of remote files and move every file to a different remote folder based on some rules?

You need Session.ListDirectory and Session.MoveFile methods of WinSCP .NET assembly:
https://winscp.net/eng/docs/library
https://winscp.net/eng/docs/library_session_listdirectory
https://winscp.net/eng/docs/library_session_movefile
_________________
Martin Prikryl
ahd262

Guest


Hi
I would like to loop on each zip files in a source directory and move the unzipped content to the folder N
It means if i ve 3 zip files i ve to read and unzip 3 files and move the content resoectively to the folder 1, 2 then 3
The nuumber of files is not known in advance
Do u advise me to use Session.ListDirectory or a foreach loop container with SSIS ?
Thx
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24998
Location: Prague, Czechia
Is the target folder local or remote?
_________________
Martin Prikryl
ahd262

Guest


the both in remote
ahd262

Guest


Sorry the both (source & destination) are in remote
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24998
Location: Prague, Czechia
Do you want them to be extracted in-place on remote side (complicated, if possible at all) or download the archives, extract and upload the contents?
_________________
Martin Prikryl
ahd262

Guest


No I would prefer to execute the process only in remote (faster)
For each file saved in source folder I have to :
mv to its specific folder
unzip it
and rename the unzipped files
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24998
Location: Prague, Czechia
Unzipping archive on the remote side is problematic.
You might be able to use Session.ExecuteCommand to execute unzip on the server, if you fit into the method limitations.
See
https://winscp.net/eng/docs/library_session_executecommand
https://winscp.net/eng/docs/remote_command
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License