Here's a useful little program for synchronizing files between folders and easily creating backups.
All you do is enter two folders into the space provided, and click the "Add" button each time. When you have two or more folders in the list, click "Sync Now" to synchronize the files between them. In other words, FileSync compares the folders with each other and copies the most up-to-date versions of each file. When FileSync is finished doing its work, both folders should be mirrors of each other.
As an alternative to typing in the full directory path, or using the "Browse" button, you can also drag a folder icon from an Explorer window onto the list to add it.
If you check "Recursive", the entire directory structure of the two folders is synchronized, with the exception of empty folders (i.e. subfolders are not synchronized unless they actually contain something.)
Where it says "Name/Extension filters" is the filespec box. If you want to copy only certain file types, change this box. For example, if you only want to synchronize Word Documents, type *.DOC. Or, if you want to synchronize Word and WordPerfect documents, type "*.DOC;*.WPD".
New in v1.5:
- New command-line switches: /Q, /A, /L, /LR, /?
- Command-line switches can be referred to with a dash now: -S, -ST
New in v1.45:
- I have added a "Date Warning" feature, which warns you before transferring a file that has a date in the future. I added this feature after I lost about 20 hours of work when my laptop's system clock messed up.
- The current date is now shown in the title bar. Don't worry, it's Y2K compliant. It'll be about 2021 before it actually fails. :)
New in v1.4:
- I have added an "exclusion filter" box, where you can add filters you don't want copied. This overrides the desired filters, so for instance you could use:
Name filters desired: *.*
Exclusion filters: *.dat;*.dll;unwanted.*
This would copy everything except files of type .dat and .dll, and files named "unwanted".
- All filters are processed in one pass. This speeds up synchronization when you have several file specs, especially when working over a slow connection such as direct cable connection.
- Bug fixed where AutoCreate reverts to "Ask Me".
The "Auto-Create" option specifies what to do when a file exists in one directory but not the other. If "Yes", files from one folder will be created in the other folder automatically. If "No", updated files will only be copied if they already exist in both locations. If you choose "Ask Me", it will ask your permission before creating every nonexistant file.
You can synchronize as many folders as you want. UNC Paths are supported. Be sure to use backward slashes rather than forward slashes.
You can also synchronize more than one SET of folders. That is what the "Synchronization sets" box is for. The first time you run the program, there is only one set, and it is called "Untitled". (You can rename this set to anything you want by clicking on "Untitled", typing in a new name and clicking "Rename".) This is for when you want to synchronize different sets of things. For example, you might want to synchronize your documents, in the directories "C:\Bill's Documents" and "\\backup\\Bill's documents", and your CAD work, in "C:\CAD\Bill", "\\backup\Bill's CAD work", and "A:\CAD Backup". To do this, you need to create two sets - one called, perhaps, "Documents" and the other "CAD Work Backup". Put the two document directories in the first list and the three CAD directories in the second list.
The sets you make need have nothing to do with each other, and can be synchronized separately. Also, you can have as many sets as you want, limited only by the scope of your workload :)
Individual directories can be set as "Destination Only". This means that no files will be copied from the directory, even if they are newer. This option is useful for directories you want to use primarily for backup.
This program can be dangerous because there's no way to "undo" a synchronization. So step one before you try using this program is to make sure that the system clock on all systems involved is correct, and file integrity is okay when you're syncronizing with a floppy.
All the lists are saved automatically in the registry when you exit the program, so you can synchronize the folders again later.
WILDCARDS:
Because of a change in coding, I have to process wildcards manually. The extension part of the filename is matched separate from the name part; for example, if your spec is "*.htm*", and a file is called "hello. Have a nice day.html", then
- "hello. Have a nice day" is matched against "*", which is a positive match.
- "html" is matched against "htm*", which is also a positive match.
If either part comes back negative, then it is considered a negative match. The matching is not case-sensitive.
I have not tested my wildcard matching code extensively; if you find something that doesn't work right, let me know!
Supported wildcard forms:
Star at beginning:
e.g. *hello matches hello and abcdhello, but not olleh or helloabcd.
Star at end:
e.g. hello* matches hello and helloabcd, but not hidude or abcdhello.
Star in middle:
e.g. he*en matches heaven and heen, but not crappyheavem or hen.
Stars on end:
e.g. *quit* matches quite, noquitting, and "I Quit, I Really Quit!".
You can't put multiple stars in any other form: *a*b*c is invalid, and so is a*b*. Such forms will never match.
You can also use question marks. For instance, ????* forces the filename to be at least four characters long, and mp? will match mp2, mp3, and mpx but not mp22, mp, or mymp3.
FileSync behaves differently if your filespec is missing the dot (.) or if there is nothing on the left or right side of the dot.
- If there is not dot (e.g. "hello") then any extension matches.
- If there is nothing on the left side of the dot (e.g. ".txt" then any filename matches.
- If there is nothing on the right side of the dot (e.g. "hello." then a filename matches only if it has no extension.
COMMAND-LINE INTERFACE:
This program is written in Visual Basic, and as such, it requires Windows to run. Therefore, you can't put it in your AUTOEXEC.BAT. However, if you want a set of directories to be sync'd automatically when you start Windows, you can do that. Here's how:
- Create a shortcut to FileSync.exe in the Start Menu under Programs | Startup
- Right-click on the shortcut and choose "Properties".
- Where it says "Target", append, in quotes, the name of the Sync Set. For example, if it said
FileSync also supports a number of switches, which are not case sensitive, and can appear before or after the list of sync sets, or whatever - this program's command line parser not being as stupid as some others I know.
- If you want the main FileSync window to appear during the sync, use /S.
C:\FileSync\FileSync.exe /s "Bill's $40M house design files"
- If you want the window to appear, but only temporarily, use /ST.
The "t" causes the window to close as soon as syncing is completed.
If neither of these is used, FileSync will run "silently", except to inform you of errors or ask whether to create a file.
- /Q ("Quiet Mode") will cause FileSync not to display error messages on screen.
It is highly recommended you use a log file with this switch (/L, /LR)
... Otherwise if something goes wrong there'll be no telling what it was
- /Lpath_and_filename will cause output to be logged to the specified file.
There cannot be a space between /L and the path, and if the path contains spaces,
I'm pretty sure you have to enclose the filename AND the switch in quotes, as in:
"/Lc:\Some dumbarse put spaces\in their path\SyncLog.txt"
- /LRpath_and_filename will cause the log file to be cleared before logging begins.
*** By the way, if you know of an employment opportunity in the programming field, especially one in Calgary, Alberta.... I would love to hear about it!
P.S. The included source code files are not needed for the program to function... only the .EXE and the VB5 runtime DLL are needed to run this program.
P.P.S. Thanks to Terry Meritt for the code for the "Browse..." button.