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.

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

martin

Re: Using monthname and year function in WinSCP

Well, this seems to be a VB question, not a WinSCP question.
Anyway, one thing I can see is missing space between the month name and year:
MonthName((Month(DateAdd("m",-1,Date()))),True) & " " & Year(Date())


Alternatively, WinSCP itself can generate such name format. Though it can subtract only days, not months:
"""put \\myserver\ABC\HMC-Data_for_ABC%TIMESTAMP-28D#MMM YYYY%.csv """

https://winscp.net/eng/docs/scripting#timestamp_batch
DWVZ2000

Using monthname and year function in WinSCP

I am trying to use WinSCP to send a file monthly where the file name is going to change every month. For example, this month the file name will be HMC-MYFILE DEC 2025, and next month it would be HMC-MYFILE Jan 2026. Below is the script I am using, but WinSCP is not finding my file. Could someone tell me how to change this script to be able to find the file. Thank you very much for your help. The file name is HMC-Data_for_ABC - Dec 2025.csv. I understand that the year will probably be 2026, but I changed the file name to have the 2026 year in it and it still didn't find it. Below is the command line.
="C:\Program Files (x86)\WinSCP\WinSCP.exe /console /command  ""option confirm off"" ""open ABC"" ""put \\myserver\ABC\" & " HMC-Data_for_ABC - " & MonthName((Month(DateAdd("m",-1,Date()))),True) & Year(Date()) & ".csv """

Thank you again for your help.