Call now to talk to an automation expert — (512) 345-2211

Script Library

Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.


archive_rename.s

Download

Sample to get each file in the "output" directory (could be any directory), send the file, rename the file with the date, and move it into the "output-archive" directory.

This script demonstrates numerous Robo-FTP features:

  1. Using GETNEXTFILE to iterate through a directory
  2. Using string manipulation and built-in date variables to build custom file names.
  3. Using filesystem commands to move local files

  1  FTPLOGON
  2  ;; set output_directory and archive_directory
  3  ;; NOTE: need to use the full path here
  4  SET output_directory = "C:\Program Files\Robo-FTP\output"
  5  SET archive_directory = "C:\Program Files\Robo-FTP\output-archive"
  6  
  7  ;; Set the working directory to the "output" directory
  8  WORKINGDIR output_directory
  9  
 10  :loop
 11  ;; Get a file from the working directory
 12  ;; NOTE: if successful this will set the "%nextfile" internal
 13  ;;       script variable to the file name found
 14  GETNEXTFILE "*"  
 15  IFERROR RETURN $ERROR_SUCCESS
 16  
 17  ;; set file_found to "%nextfile"
 18  SET file_found = %nextfile
 19  ;; file was found, send it
 20  SENDFILE file_found 
 21  IFERROR RETURN
 22  
 23  ;; rename the file with the date
 24  ;; do string manipulation to "break" up file name found to 
 25  ;; get the base name from the extension
 26  ;; NOTE: this sample is assuming a 3 character extension 
 27  ;;       will be used
 28  SET base_name = file_found
 29  ;; set 4 characters on the right to extension and split 
 30  ;; apart remaining
 31  SETRIGHT extension = base_name "4" /split

 32  ;; set archive_name to base_name + %date + extension
 33  SET archive_name = base_name & %date & extension
 34  ;; rename file_found to archive_name
 35  RENAME file_found archive_name
 36  
 37  ;; set the archive_path to archive_directory + "\" + archive_name
 38  SET archive_path = archive_directory & "\" & archive_name
 39  ;; move the file to archive_path
 40  MOVE archive_name archive_path
 41  
 42  ;; loop
 43  GOTO loop
 44  

Browse complete list of scripts

Need help figuring out where to start?

Our sales staff is available to answer product questions and help you determine if Robo-FTP is a good match for your project.

Call Now: (512) 345-2211