使用WinSCP从名称为会计年度的文件夹上载到SFTP服务器 [英] Use WinSCP to upload from a folder with a fiscal year in its name to an SFTP server

查看:40
本文介绍了使用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"" ^

这篇关于使用WinSCP从名称为会计年度的文件夹上载到SFTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆