ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Post here if you experience file transfer problems or unexpected errors.
Hi.
Is it possible to manage the renamefile command to override an existing file?

Sometime i have a Return Code issuing that the file exist (i.e)
***** RENAMEFILE Error #17553: Cannot rename remote file FATT105201207201050388.dasped to FATT105201207201050388.pdf.
***** The server said: file exists


Error rename remote
An Error was found during remote rename files.


I need to override it.
Is it possible?
Best regards.
FTP Script
  1. DELETEFILE('filename.pdf')
  2. RENAMEFILE('filename.dasped', 'filename.pdf')
Hi.
Thanks for your support.

In my script I use the following statements:

[ScriptFTP]$result_rename_remote=renamefile("*.dasped","*.pdf")
IF($result_rename_remote!="OK")
PRINT("Error rename remote")
GOTO :failed_remote_rename
END IF[/ScriptFTP]

Is it possible to insert your suggestion (i can't write the name of the file because they can vary) ?
Note that not all pdf must be deleted in advance because may be that there are some other PDFs not ftped.

Best Regards
Hi,
Is it possible to insert your suggestion (i can't write the name of the file because they can vary) ?
With the GETLIST command is possible. Try the following:
FTP Script
  1. # Get the list of the remote .dasped files
  2. GETLIST($remote_file_list,REMOTE_FILES,"*.dasped")
  3.  
  4. # For each .dasped file ...
  5. FOREACH $remote_file IN $remote_file_list
  6.  
  7.     # the PDF file name will be
  8.     $pdf_filename=TEXTCUT($remote_file,1,TEXTLENGTH($remote_file)-7).".pdf"
  9.  
  10.     # To prevent RENAMEFILE failing delete the PDF file first
  11.     DELETEFILE($pdf_filename)
  12.  
  13.     # Rename the file
  14.     RENAMEFILE($remote_file,$pdf_filename)