Kindly see the following screencasts to get better idea about our requirement:
<invalid hyperlink removed by admin>
<invalid hyperlink removed by admin>
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:
- Use WinSCP FTP Client with Scripting
- Write script to get the most recent updated file from FTP Folder
- Or instead of step 2, download all generated files from FTP to a Shared Folder on the Network.
- Get the most recent version of the Generated CSV File
- Rename the file to the Standard Naming Convention. This must be the name used in MS Excel as the CSV Text Datasource.
- 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:
winscp.com /script=example.txt
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.
Tarek