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.


tree_to_flat.s

Download

The first time this sample script is executed, it downloads all the files from a remote directory tree into a single local folder. On subsequent executions it only downloads new files and files that have been changed since the last execution.

One side-effect of downloading a remote directory tree into a single local folder is that files with the same name but in different folders on the remote side will overwrite each other when downloaded locally. For example:

/File1.txt → c:\flat\destination\File1.txt

/sub/File1.txt → c:\flat\destination\File1.txt

/sub/deep/File1.txt → c:\flat\destination\File1.txt

It is possible to add script logic to only overwrite an older or smaller file (or some other condition) but that is beyond the scope of this sample script.


  1  WORKINGDIR "c:\flat\destination"
  2  FTPLOGON "ManagedSite"
  3  IFERROR RETURN
  4  FTPDIFF "*" /incldirs /append 
  5  :process_next_file 
  6  FTPGETDIFF /commitlast 
  7  IFERROR RETURN $ERROR_SUCCESS
  8  IFNUM= %ftpdifffileid $DIFF_FILE_NOT_FOUND GOTO process_next_file
  9  RCVFILE %ftpdifffilename /from=%ftpdifffilepath 
 10  IFERROR RETURN
 11  GOTO process_next_file

Browse complete list of scripts