Compare File Date Using IsFileNewerByDate

Updated by Hari Prasad on

This custom trigger function is used to get the status of the file on whether the file is really new against another or similar file by comparing against a custom date.

See How to Create Custom Trigger Functions for details on installation.

Downloads

Source code and build instructions

How to move a file to a different folder using IsFileNewerByDate comparing  it against a custom date

Let me now show you how to implement that.

 

1. Make sure you have IsFileNewerByDate function installed

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

 

2. Create a Trigger to Compare a File Against a Custom Date on File Upload

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. 

 

is_file_newer_by_date_img1

 

Click Next to Step 2 to set the condition to check the file modification time using IsFileNewerByDate function

Use the below condition;

Click Functions button to select the IsFileNewerByDate(file,dd/mm/yyyy) function. If the function not listed you need to have build installed in the server.

Use the condition with below syntax,

 

IsFileNewerByDate(file,"dd/mm/yyyy") = TRUE

 

is_file_newer_by_date_img2

The above expression helps to check the uploaded file against a custom date. Consider an example, that we don't need files in the server older than a particular date. This function will help you in it by passing the date parameter along the file that gets uploaded to the server. In this example this function will help to accept files after the said date moving them into a different folder.

 

This scenario can be reversed as well by accepting the files not after the custom date using "FALSE" condition. Example by using the condition as ; IsFileNewerByDate(file,"dd/mm/yyyy") = FALSE

 

Click Next to proceed. On TRUE move the files. On Step 3 an action has to be added, in order to add an action click Add button 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)

If the file has to be overridden then the destination directory can be the location where the file actually exists.

 

check_directory_size_img5

Click Ok to save the settings. That's it. Now you know how to use the custom function IsFileNewerByDate and move file on threshold.

Downloads

Download JSCAPE MFT Server

Topics: JSCAPE MFT, Functions

Get A Free Trial

Download Your 7-Day Free Trial Version of JSCAPE MFT Server.

Get Your Free Trial