- martin
Post a reply
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Topic review
- vincentl
Download file with file name prefix of timestamp
Hi,
I would like to know whether is there any script that has already shared that could download specific file based on the filename which has the timestamp of current date.
example:
Today's system date is 2017-01-19 (yyyy-mm-dd) the filename would be SI_2017-01-19_ABC_0981_ALL.csv
The FTP site folder has all daily files and I would only need to download a specific file of the day. Everyday the filename would change based on the system date where the prefix is not change.
Filename: SI_YYYY-MM-DD_ABC_0981_ALL.csv , the YYYY-MM-DD would be based on today's system date.
Winscp Version 5.5.6 (build 4746)
Thank you very much.
I would like to know whether is there any script that has already shared that could download specific file based on the filename which has the timestamp of current date.
example:
Today's system date is 2017-01-19 (yyyy-mm-dd) the filename would be SI_2017-01-19_ABC_0981_ALL.csv
The FTP site folder has all daily files and I would only need to download a specific file of the day. Everyday the filename would change based on the system date where the prefix is not change.
Filename: SI_YYYY-MM-DD_ABC_0981_ALL.csv , the YYYY-MM-DD would be based on today's system date.
Winscp Version 5.5.6 (build 4746)
Thank you very much.
- martin
Re: Scripts can use env variables
This is documented on a beginning of scripts commands section.
- LeeMeador
Scripts can use env variables
I suggest documenting better the fact that we can now (as of some version between 3.8 and 4.1.8) use %envvar% inside WinSCP scripts. All I found was it used in some example scripts. The main "script" page should have added somthing like:
You can use environment variables inside scripts similar to the way you can inside Windows batch files. Use the form %var1% in the script file and it will be replaced when the script is running by the current value of the environment variable "var1". You can set environment variables from the Windows command line with the command "set var1=\files\file1.txt" or they can be set from the system control panel. Click "Advanced" tab then the "Environment Variables" button and you can add and modify values. Note that the values you set under the control panel editor become active when you open a new DOS box but the "set" command causes instantaneous changes.
Or something like that. Maybe an example with a batch file and a script would make it clearer.
-- Lee
You can use environment variables inside scripts similar to the way you can inside Windows batch files. Use the form %var1% in the script file and it will be replaced when the script is running by the current value of the environment variable "var1". You can set environment variables from the Windows command line with the command "set var1=\files\file1.txt" or they can be set from the system control panel. Click "Advanced" tab then the "Environment Variables" button and you can add and modify values. Note that the values you set under the control panel editor become active when you open a new DOS box but the "set" command causes instantaneous changes.
Or something like that. Maybe an example with a batch file and a script would make it clearer.
-- Lee