使用WinSCP从名称为会计年度的文件夹上载到SFTP服务器
我当前正在运行一个包含WinSCP命令行的批处理文件,该命令行将文件从子文件夹上载到SFTP服务器.该命令的编写方式如下:
I am currently running a batch file that contains a WinSCP command line that uploads a file from a child folder to an SFTP server. The command is scripted as such:
put ""C:\Finance\FY 2021\%%TIMESTAMP#yyyymmdd%%\file.txt"" ^
问题是,父文件夹( FY 2021
)每年10月1日更改.因此,我目前将设置一个任务,以手动修改 FY 2022
的路径, FY 2023
等,直到9月30日结束.是否可以编写命令脚本,以便可以自动进行此更改?更改意味着目标目录路径.谢谢!
The problem is, the parent folder (FY 2021
) changes every October 1. So I currently will set a task to manually modify the path to FY 2022
, FY 2023
and so on, at the end of the day on September 30. Is there a way to script the command so this change could be automated? Change meaning the target directory path. Thanks!
您可以使用WinSCP的未来时间戳语法.距 10月1日之后,到今年年底为止有61天.因此,如果您将时间戳记添加62天,则所得时间戳记的日历年将等于原始时间戳记的会计年度.
You can make use of future timestamp syntax of WinSCP. There are 61 days to the end of the year after October 1. So if you add 62 days to a timestamp, the calendar year of the resulting timestamp will be equal to the fiscal year of the original timestamp.
有了这些知识,以下内容将产生会计年度:%TIMESTAMP + 62D#yyyy%
With that knowledge, the following will produce the fiscal year: %TIMESTAMP+62D#yyyy%
在批处理文件中,您可以像这样使用它:
In your batch file, you can use it like this:
"put ""C:\Finance\FY %%TIMESTAMP+62D#yyyy%%\%%TIMESTAMP#yyyymmdd%%\file.txt"" ^