Topic "Move all files between the same sftp server"

Author Message
Invitado

Guest


Hi!

I need to copy files from a sftp server to our server, and then, move the files in the original dir to a subdir.

open sftp://user:password@server
cd /incoming/out
option exclude "processed/"
lcd \\server\sftp\IN\
mget *
close

Thats the part that works ok. But i dont know how to make the second step.

Maybe creating a mask? Something like this

cd
cd /incoming/out
put -filemask="|*/" *.gpg
mv *.gpg /incoming/out/processed/

give me the log message:

* 2017-05-15 15:10:00.919 (ETerminal) Permission denied.
* 2017-05-15 15:10:00.919 Error code: 3
* 2017-05-15 15:10:00.919 Error message from server: Permission denied
. 2017-05-15 15:10:00.919 Asking user:
. 2017-05-15 15:10:00.919 Cannot overwrite remote file '/incoming/out/file'.$$
. 2017-05-15 15:10:00.919
. 2017-05-15 15:10:00.919 Press 'Delete' to delete the file and create new one instead of overwriting it.$$ ("Permission denied.
. 2017-05-15 15:10:00.919 Error code: 3
. 2017-05-15 15:10:00.919 Error message from server: Permission denied")
< 2017-05-15 15:10:00.919 Script: Cannot overwrite remote file '/incoming/out/file'.
< 2017-05-15 15:10:00.935 Script: Permission denied.
< 2017-05-15 15:10:00.935 Error code: 3
< 2017-05-15 15:10:00.935 Error message from server: Permission denied
* 2017-05-15 15:10:00.935 (EScpSkipFile) Cannot overwrite remote file '/incoming/out/file'.$$
* 2017-05-15 15:10:00.935
* 2017-05-15 15:10:00.935 Press 'Delete' to delete the file and create new one instead of overwriting it.$$
* 2017-05-15 15:10:00.935 Permission denied.
* 2017-05-15 15:10:00.935 Error code: 3
* 2017-05-15 15:10:00.935 Error message from server: Permission denied
. 2017-05-15 15:10:00.935 Script: Failed
. 2017-05-15 15:10:00.935 Script: Exit code: 1
. 2017-05-15 15:10:00.935 Closing connection.
. 2017-05-15 15:10:00.935 Sending special code: 12
. 2017-05-15 15:10:00.935 Sent EOF message


Can you help me?

Regards!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26480
Location: Prague, Czechia
mv * /incoming/out/processed/

I do not know what the purpose of *.gpg mask, as you have not mentioned that in your post.

---

Though the above solution is not transactionally safe. If new files are added during download, it will move even those files, although they were not downloaded.

There's an example for transactionally safe upload, with use of PowerShell script and WinSCP .NET assembly.
You can base your solution on that:
https://winscp.net/eng/docs/script_local_move_after_successful_upload
Advertisements

You can post new topics in this forum






Search

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