Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

impho

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

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.