DIFF Look for differences in the local PC file system |
Top Previous Next |
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 |