I think this should do what was asked.
I used composer to import phpseclib so this is not exactly the code I tested, but from the other answers, the syntax should be correct.
<?php
include('Net/SFTP.php');
// connection
$sftp = new Net_SFTP('website.com');
if (!$sftp->login('user', 'pass')) {
exit('bad login');
}
// Use sftp to make an mv
$sftp->exec('mv /jn/xml/* /jn/xml/backup/');
Notes:
- if any of the directories do not exist, this will fail. do
echo $sftp->exec(...
to get the errormsg.
- you will get a warning because /jn/xml/backup/ is inside /jn/xml/, I would advise moving the files to /jn/xml.bak/
- you could use 'Net/SSH2' class, since you only do a mv, and do not transfer any files. In fact, the exec is a function from the SSH2 class, and SFTP inherits it from SSH2.