Using monthname and year function in WinSCP

Advertisement

DWVZ2000
Joined:
Posts:
11
Location:
USA

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
42,605
Location:
Prague, Czechia

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

Reply with quote

Advertisement

You can post new topics in this forum