DIFF        Look for differences in the local PC file system

<< Click to Display Table of Contents >>

Navigation:  Robo-FTP User's Guide > Script Programming > Script Commands > All Script Commands >

DIFF        Look for differences in the local PC file system

Syntax:

DIFF

[ path ] [ dbfile ] [ /options ]

Arguments:

[ path ]

Optional variable or string defining the starting local path from which to begin looking for differences; if omitted, the current local working folder is searched and [ dbfile ] defaults to “snapshot_local.sql”.

 

[ dbfile ]

Optional variable or string specifying a snapshot database file. If omitted, the default value is “snapshot_local.sql”. This argument may only be specified if [ path ] is also specified. When [ dbfile ] is specified without a full path the alternate default path is used.

Options:

/append

Add differences to the existing database instead of creating a new list of differences. This is useful if your automation logic requires deferring the next action until some minimum number of differences are found.

 

/incldirs

Descend into sub-folders below the folder specified in the [ path ] argument

 

/noupdate

Do not update the database with differences found.

 

/timeout=#

Specifies the number of seconds to wait for a difference to be found. A %datetime value can also be given as an argument instead of a number of seconds.

 

/difftype=xx

Specify the type of changes that will be added to the database. You can either use this option multiple times or separate the values with a pipe character. See the section regarding %difffileid in the GETDIFF article for a list of possible options.

 

 

Note

Robo-FTP offers numerous commands for monitoring for files and iterating over directory structures on local and remote servers. There is significant overlap in capabilities between these commands, but there are also important differences that often make one command better suited to a particular task than the others. Please see the chapter Monitoring for Files and Iterating over Directory Structures for a description of these commands and recommendations for which commands to use in a particular situation.

 

The DIFF and GETDIFF commands work together to identify and process changes to local files.

 

The DIFF command detects changes in the portion of the file system specified by the [ path ] argument using a small database file specified by the [ dbfile ] argument. This command adds a record to a "snapshot database" for each file listed in directory listings provided by the local operating system. Empty folders and files with the "hidden" or "system" attribute are ignored. The DIFF command then compares the new database records that represent the current state of the file system to the old records that represent the previous state of the file system and notes all differences. The differences are available to be processed, one at a time, by the GETDIFF command.

 

If the file specified by the [ dbfile ] argument does not exist it will be created. The time required to create a new database depends on how many files are present. Since new snapshot databases do not contain any rows representing the previous state of the file system, all files added to a new database will be recorded as "new" files. If you don't want GETDIFF to identify all files as new on the first execution of your command script then you can run this command once in Robo-FTP's main console window to establish a baseline snapshot database. This way, when you first run your command script, only file changes since the baseline will be detected.

 

Note: The fact that all files are considered "new" in a freshly created snapshot database can be exploited to process folders with dynamic contents.

 

The total number of differences found in the local PC file system is saved in the %difffiles script variable.

 

Consider the following example which compares the state of the current working folder with the previous state of the file system as preserved in the default “snapshot_local.sql” file and then only uploads the changed files:

 

DIFF "*"

:loop

GETDIFF

IFERROR= $ERROR_READ_EOF GOTO done

;; skip upload if the "change" is that file is gone!

IFNUM= %difffileid $DIFF_FILE_NOT_FOUND GOTO loop

SENDFILE %difffilepath

GOTO loop

:done

 

FTPDIFF is the equivalent command for detecting differences in the remote file system.

 

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): GETDIFF, DIFFREWIND, FTPGETDIFF, FILECOMEPAREFROM, SYNC

See also: Using the built-in database engine, Processing Dynamic Folders, Alternate Default Path