在 Windows 命令行中上传到 FTP 之前重命名本地文件

Posted

技术标签:

【中文标题】在 Windows 命令行中上传到 FTP 之前重命名本地文件【英文标题】:Rename local file before upload to FTP in Windows command-line 【发布时间】:2018-07-24 08:28:16 【问题描述】:

我有以下脚本由于某种原因无法正常工作。 我需要每天重命名(附加当前日期)Feed.txt 文件并将其上传到 FTP。我错过了什么?

eco
secret_pwd
ascii
lcd C:\Jobs
rename Feed*.txt Feed_%date:~-4,4%%date:~-7,2%%date:~-10,2%.txt
cd Uploads
put Feed_%date:~-4,4%%date:~-7,2%%date:~-10,2%.txt
quit

【问题讨论】:

【参考方案1】:

renameftp.exe 脚本中重命名 FTP 服务器上的文件。

当您要重命名本地文件时。为此,您需要使用cmd.exerename 命令,而不是ftp.exe

因此,要么将rename 移动到执行您的 FTP 脚本的批处理文件中(如果有)。

或在rename 前加上! 以指示ftp.exe 转义到cmd.exe

【讨论】:

以上是关于在 Windows 命令行中上传到 FTP 之前重命名本地文件的主要内容,如果未能解决你的问题,请参考以下文章

sh 在18行Shell中上传到S3(用于上传http://soltrader.net的版本)

Windows XP下如何使用SCP命令将文件传到局域网中的Linux机器

将所选图像从库中上传到gridview

windows命令行怎么使用ftp

将图像从库中上传到服务器

在Windows命令行中将子文件夹上载到FTP