Call Us: 866.PICK.ITS or Have Us Contact You:
Robin Story, FileMaker Consultant, IT Solutions
As mentioned in Data Migration Tool Overview: Part One, the Data Migration Tool (DMT) in FileMaker 17 uses the Command Line Interface, which means that the whole process could involve a pretty intricate set of instructions typed into the shell. And the longer a shell command gets, the easier it is for a typo to cause the whole thing to fail. And who needs that frustration? Is there a way to build a Graphic User Interface (GUI) skin for the DMT so that the commands are processed automatically?
The answer is: Yes! For both Mac and PC!
Step 1: Set Up Your Workspace
To get started, we’ll need to set up a working directory. We’ll keep the DMT executables here, keep our FileMaker front end in it, and output results to this directory.
First, let's create a folder called "Data Migration Tool Helper." This folder can be placed anywhere on your system, but for this demonstration, we'll go ahead and drop it on the desktop. Inside of this folder, let’s add two FMDataMigrationTool folders – one for the Mac executable and one for the PC executable. In order to distinguish them, I'm going to name the PC folder FMDataMigrationTool_WIN and leave the mac folder named as just FMDataMigrationTool.
Next, we want to create a FileMaker file in our Data Migration Tool Helper folder. We're going to call it .... you guessed it... Data Migration Tool Helper.fmp12
We only need one table to get the basic functionality down, and we're going to start simple, with a source and clone file that are unprotected and unencrypted. So for our demo, all we need is the source filename (Contacts.fmp12 ) and the clone filename (Contacts Clone.fmp12), and then a text field to store the results.. We're going to assume that both source and clone files will be in the Data Migration Tool Helper folder, and that the migrated file will be placed in the same folder. Once we get this working, we can build the rest of the solution out from there:
Here's what that folder for the Data Migration Tool on our desktop looks like:
As you might have already guessed, FileMaker is going to handle the actual run of the DMT via script, so the next step will be to build that script:
Step 2: Build Your Script
Find out what platform you’re running
The important thing to point out as we get started is that the syntax for running the Data Migration Tool is identical between both Mac and PC. The difference between them is how the Mac and the PC handle Command Line paths, and the subsequent results. So the very first thing your script should contain is some way to determine what platform you’re currently running on. To keep things simple we’ll just set a variable to 1 if the platform is Mac:
Set Variable [$isMac; Value: Get(SystemPlatform) = 1]
Build file path to Source and Clone
As mentioned above, we are assuming both source and clone files will live in the same directory as our FileMaker front end file. This helps us determine file paths automatically because we can use Get(FilePath) in our front end file to get the path to the parent directory, and build a complete path by combining the parent directory path with source and clone file names.
Get(FilePath) gives a “filemaker” style filepath, however, which won’t work in the DMT command line, so we will need to translate the output of Get(FilePath) into platform-ready variables:
This means that we have the following variables:
Build Parameter String for the DMT command line
Next, we'll want to go ahead and create a $parameters variable to store our DMT command's parameters in. We're going to start with just the barest of bare-bones by just having the source and clone path, and also indicating that we want it to run in verbose mode for maximal feedback. Since these parameters are cross-platform, we can put this in one place and not need to write it out twice, which is handy!
Set Variable [ $parameters;
" -src_path " & $q & $filesLocation & Data Migration Tool Helper::Source_FileName & $q &
" -clone_path " & $q & $filesLocation & Data Migration Tool Helper::Clone_FileName & $q &
" -mode -v"
Building the Script
With the parameters in place, we can go ahead and start constructing the script itself. Let's start with the Mac version since that's a bit simpler:
Perform AppleScript [
"set mySlug to do shell script "" & $scriptLocation &