We want to automate the Text Datasource Generation and connection to MS Excel in order to make it easier to the end-user to connect to the Text Datasource (CSV) to MS Excel so that they can generate their own reports.
The steps I have in mind:
1. Use WinSCP FTP Client with Scripting
2. Write script to get the most recent updated file from FTP Folder
3. Or instead of step 2, download all generated files from FTP to a Shared Folder on the Network.
4. Get the most recent version of the Generated CSV File
5. Rename the file to the Standard Naming Convention. This must be the name used in MS Excel as the CSV Text Datasource.
6. Delete all other files
I developed sample script that can be used by WinSCP to download the files from FTP folder:
# Automatically abort script on errors option batch abort # Disable overwrite confirmations that conflict with the previous option confirm off # Connect open CSOD # Change remote directory cd /Reports/CAD # Force binary mode transfer option transfer binary # Download file to the local directory d:\ #get "Training Attendance Data - Tarek_22_10_21_2014_05_05.CSV" "D:\MyData\Business\Talent Management System\Reports\WinCSP\" get "*.CSV" "D:\MyData\Business\Talent Management System\Reports\WinCSP\Files\" # Disconnect close exit
Then, I can schedule the above code to run periodically using this command:
The above sample is working fine, but the main problem is how to identify the most recent file, so that I can rename it, and delete all the other files.
Our ultimate objective is to automate the download of the CSV Files from FTP Folder, to make it easier for end-user to use them to connect to client reporting engine like MS Excel.
Appreciate your help.
Last edited by tarekahf on 2014-10-29 14:48; edited 1 time in total