Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

As the FTP protocol use the same command to rename files or directories you have to use also the RENAMEFILE command to rename directories:

OPENHOST("ftp.myserver.com","carl","123456")
 
# Rename the directory name
RENAMEFILE("mydirectory","mynewdirectoryname")
 
CLOSEHOST

 

A more complex example that uses the FOREACH loop to rename multiple directories

 

SETPROTOCOL(SFTP)
OPENHOST("ftp.myserver.com","carl","123456")
 
# Change current remote directory to to_be_processed
CHDIR("to_be_processed")
 
# Do the processing with an external tool
$result = EXEC("C:\tools\run_process.exe")
 
# If the external tool returned 0 means
# that it was completed successfully so rename the remote dirs
IF($result==0)
    GETLIST($list,REMOTE_DIRECTORIES)
    FOREACH $directory_name IN $list
	   RENAMEFILE($directory_name,$directory_name."-processed")
    END FOREACH
END IF
 
CLOSEHOST