GETDIFF Get specific changes within local PC file system |
Top Previous Next |
The DIFF and GETDIFF commands work together to identify and process changes to local files.
The GETDIFF command sets the values of five internal variables with details describing a change to a single local file. These details are pulled from a snapshot database where they were inserted by a previous call to the DIFF command. Subsequent calls to GETDIFF fetch the details of subsequent changes from the database. The GETDIFF command is typically used in a loop so that each detected change is processed during one iteration of the loop. Depending on your needs, the processing may involve one or more of the internal variables set by this command. It is possible for GETDIFF to report file changes in alphabetical order rather than folder hierarchical order depending on how the records are stored in the snapshot database. This command returns $ERROR_READ_EOF when there are no more differences in the database. The DIFFREWIND command is available to reset the file pointer to the first change recorded in the database.
If the [ dbfile ] argument is omitted, the default file name “snapshot_local.sql” file is used. An error occurs if the snapshot database file does not exist.
The GETDIFF command sets the values of the following variables that you can use in your script logic:
The possible values of %difffileid and %difffiletext are:
Here is a simple example that shows how GETDIFF might be used inside a loop to write a text file that lists all the changes found by DIFF:
DIFF "*" :loop GETDIFF IFERROR= $ERROR_READ_EOF GOTO done SET change = "File: " + %difffilepath + " " + %difffiletext WRITEFILE "differences.txt" change /append GOTO loop :done
The following example loops through all changes and uploads only the new files to a remote site:
DIFF "*" :loop GETDIFF IFERROR= $ERROR_READ_EOF GOTO done IFNUM!= %difffileid $DIFF_FILE_IS_NEW GOTO loop SENDFILE %difffilepath GOTO loop :done
Note: Snapshot database files are small SQLite database files created by Robo-FTP to support the DIFF and FTPDIFF family of script commands.
Related command(s): DIFF, DIFFREWIND, FTPGETDIFF See also: Processing Dynamic Folders, Using the built-in database engine, Alternate Default Path
|