Sort Files from SFTP Folder by Timestamp of Addition

To Sort Files Added to SFTP Server by Timestamp of Addition, Utilize the Following Function:

let list = connection.list({

                    path: ‘/Outbound Order Shipments’

                });

Here ‘Outbound Order Shipments’ is the SFTP folder to which the files are added.

           

                // Sort files by creation timestamp

                list.sort((a, b) => new Date(a.lastModified).getTime() new Date(b.lastModified).getTime());

Leave a comment

Your email address will not be published. Required fields are marked *