Move files on specific word during file upload using regular expression

Discover how to efficiently use the FileContains function to manage file uploads. This guide explains creating a custom trigger function to validate files using regular expressions before moving them on a server.
  1. Blog

This custom trigger function contains regular expression and file as parameters where the regular expression will be tested against the file. This function will help to identify validate specific constraint against the file before uploading/downloading. 

How to Move Files Using FileContains Function

Here in the example would like to take through on how to move files to a different folder on specific word in the file on file upload. Let me now show you how to implement that.

See How to Create Custom Trigger Functionsfor details on installation. In order to use this function, the build has to be downloaded. Checkout the downloads section for more details.

Downloads

Source code and build instructions

1. Make sure you have FileContains function installed

Before creating a custom trigger to use the function FileContains, you need to have build installed in the server where JSCAPE MFT Server is running.

2. Create a trigger to use the function 

Now login into admin console of JSCAPE MFT Server > Triggers and Click Add to create a Trigger. Give the trigger a Name and then select the File Upload event type from the drop-down list. 

file_contains_img_1

Click Next to Step 2 to set the condition, ClickFunctionsbutton to select the function FileContains(filepath,regex).

file_contains_img_2

If the function not listed you need to have build installed in the server. Use the below condition to check whether the word stop (irrespective of it's case) is in the file .

FileContains(LocalPath,"^stop.*$")=TRUE

 file_contains_img_3

Click Nextto proceed. On TRUE move the files.

On Step 3 an action has to be added, in order to add an action click Addbutton and select the action "Move File" from drop down list and Click OK

move_file

On OK there would be two parameters for Move File Action;

  - File (Uploaded File) - Use %LocalPath% to get the uploaded file

  - Destination Directory (Directory to be moved)

file_contains_img_5-2

Click Ok to save the settings. That's it. Now you know how to use the custom function FileContains and move file on specific word using regular expression.

Downloads

Download JSCAPE MFT Server