Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move a directory in remote server to another location in the same remote server using jsch

Tags:

java

sftp

jsch

I am using JSCH API to connect to remote server through sftp. I need to move a directory present in the remote server from location A to location B. It looks like the method channelsftp.put(src,dest) allows to move only a file and not the directory.

Can someone please explain me how to do this?

like image 994
Michael Maze Avatar asked Nov 07 '12 19:11

Michael Maze


1 Answers

You can use the rename command, it would move the file or directory and delete it from the original place.

sftpChannel.rename(oldFile, newFile);

Don't use this method, if you want to keep the original directory/file.

Hope this helps.

like image 175
Abs Avatar answered Oct 21 '22 02:10

Abs