How Can I Use File Moving Rules to Transfer Files to a Specific Folder on the NI SystemLink Server Machine?

Updated May 1, 2023

Reported In

Software

  • SystemLink
  • LabVIEW

Issue Details

I have multiple log files that are transferred from the SystemLink Client to the SystemLink Server using the file transfer API. These files appear in the file viewer interface of the SystemLink web application but I want to log them onto my system in specific folders. How can I achieve this?

Solution

When the files are transferred to the NI SystemLink Server using the file transfer API, the files are automatically populated in the File Viewer Interface. To ensure that these files are placed in specific folders on the server machine, you need to set up File Moving Rules  in the NI SystemLink server. Follow these steps to set it up:
  1. Navigate to C:\ProgramData\National Instruments\Skyline\Data\FileMoving. You will see a file named DefaultRootPath.json here. This file defines the default path to which your files are saved once they are transferred to the server. By default the file contains the following:
{
  "DisplayName": "Default",
  "Path": "C:\\Users\\Public\\Documents\\FileMoving"
}
 
To add more options, create a copy of the JSON file in the same directory and change the DisplayName and Path to your liking. For example:
{  
  "DisplayName": "Test3",  
  "Path": "C:\\Users\\Public\\Documents\\File"
}
  1.  Navigate to the File Viewer interface in the SystemLink Server web app and go to 'File Moving Rules' by clicking the 'settings' button as shown below.You will see a list of the existing file moving rules. You can modify the existing ones or create a new rule altogether.
  2. Examine the rule shown below:
    • The rule shown here is named test and the destination is Test3 which is defined by you in the JSON file as shown previously. So, files that follow this rule will be saved in C:\Users\Public\Documents\File
    • Relative Path defines the folder inside the Test3 path. This path can be any valid string such as Folder\SubFolder. You can also define the relative path dynamically using property metadata. An example of such a relative path is <Month>\<Day>\<Year>. This relative path will create folders within the root path that correspond to the specific month, day, and year values of the files. The following is a list of properties you can use as placeholders in relative paths:
      • Date
      • Month
      • Year
      • Name
      • Extension
    • You can also define Rule Matching Metadata. If you want to organize files such that only the files whose name contains -test- should follow this rule, define the property as Name, condition as Contains and the value as -test-.
  3. In the example screenshot above, custom properties are being used (Such as Last and Match). These custom metadata properties are defined in the client-side LabVIEW program as shown in the snippet below:
  4. In this program, before sending the file to the server, a couple of custom properties have been defined which are eventually used to sort the files on the server. The Last property has the value of last modified date in the format: <day> <month> <hour> <minute> and the Match property has a value of '1' (This corresponds to the rule matching metadata). So, the file Test.txt will be saved in the folder C:\Users\Public\Documents\File\1 2 17 20, assuming that the file was last modified on 1st February, 5:20 PM. Note that if the value of 'Match' had been set to anything other than '1', this file would not follow the 'test' rule.

Additional Information

You can create multiple file moving rules and use the Rule Matching Metadata feature to define what file follows what rule.