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.


oldest_to_newest.s

Download

Robo-FTP provides numerous commands that are designed to work with loops to iterate through all the files in a directory.

This example uses GETFILE. See the Help file to determine which command is most appropriate for your situation. Other commands with similar functionality include GETSITEFILE, GETNEXTFILE, and FTPGETFILE.

GETFILE provides numerous options to give you control over how it does its job. For example, the /oldest option tells GETNEXTFILE to return information on the oldest file in the directory.

This example sets up a loop that finds the oldest file in the "dailys" directory, displays the file name, then moves the file to the "processed" directory.

Instead of (or in addition to) displaying the file name you could perform other processing on each file (like adding to a zip archive, PGP encrypting, uploading, etc.).


  1  LOG "oldest_to_newest_script.log"
  2  TRACELOG "oldest_to_newest_trace.log"
  3  
  4  WORKINGDIR "C:\my documents\dailys"
  5  :loop
  6  GETNEXTFILE "*" /oldest 
  7  IFERROR RETURN $ERROR_SUCCESS
  8  DISPLAY %nextfile
  9  MOVE %nextfile "c:\my documents\processed" 
 10  IFERROR RETURN
 11  GOTO loop

Browse complete list of scripts