Move all files between the same sftp server

Advertisement

Invitado
Guest

Move all files between the same sftp server

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!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,252
Location:
Prague, Czechia

Re: Move all files between the same sftp server

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

Reply with quote

Advertisement

You can post new topics in this forum