Topic "possible to increment/decrement a date/number in script?"

Author Message
[View user's profile]

Joined: 2013-12-05
Posts: 1
Hi. I'm looking to use WinSCP as a do-everything FTP client using scripting. I've gone through the scripting area of the site as much as I can but didn't find an answer to the following questions.

1. I need to be able to recognize different date formats in the filename.
Examples: yyyy or yy for year
mmm or mm for month
dd for day
Sample filename formats: filename_yyyymmdd.txt or filename_ddmmmyy.txt

2. I need to be able to increment/decrement the date by varying amounts from the current date (example: today, Dec. 5, 2013). So for example, I would pass a parameter like +1 to increment the date that WinSCP would look for by 1 (tomorrow's date - filename_20131206.txt). Similarly, a -1 would look for the day before the current date (filename_20131204.txt).

3. I need to be able to also increment a number in the filename from a certain starting number that has a starting date attached to it. The number would have to be incremented automatically based on how long ago from today the starting date was.
For example:
Starting number: 1
Starting date: Dec. 1, 2013
So when the script runs, it checks current date (Dec. 5, 2013). It sees the current date is 4 days after the starting date and will increment the starting number by the same amount. So the filename would look something like filename_yyyymmdd_nn.txt (filename_20131205_05.txt).

Thanks for any help you can provide.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
This is definitely not something WinSCP can do for you.
You need to implement this using some scripting language.
See this example for inspiration:
Martin Prikryl

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License