windows - 将远程 FTP 主机上的文件重命名为命令的输出 (Windows)

标签 windows batch-file cmd ftp

我正在使用 cmd.exe(在 Windows 7 上)连接到我网站的 FTP 服务器。但是,当我想重命名远程主机上的文件时,我只能将其重命名为静态文本(第一个单词,如果有多个单词由空格分隔)

我想做的是将文件重命名为命令的输出(动态)。例如命令 date 的输出是

The current date is: Sat 06/18/2016

我希望文件名是 date 命令的结果。

提前致谢!

最佳答案

开始 collecting the command output to a variable .

然后,使用该变量即时生成 ftp.exe 脚本。

FOR /F "tokens=* USEBACKQ" %%F IN (`date /t`) DO (
  SET OUTPUT=%%F
)

echo open ftp.example.com>ftp.txt
echo user>>ftp.txt
echo password>>ftp.txt
echo rename current_name %OUTPUT%>>ftp.txt
echo bye>>ftp.txt

ftp -s:ftp.txt

关于windows - 将远程 FTP 主机上的文件重命名为命令的输出 (Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37894225/

相关文章:

c# - 如何在 C# (MVC 3) 中自动运行带有 3 个参数的批处理命令?

windows - Crontab 不能在 Windows 上的 Ubuntu 上使用 Bash

batch-file - 批量MysqlDump错误

batch-file - 如何让批处理文件在特定时间执行?

windows - 从命令行以编程方式打印多份副本

windows - FTYPE/ASSOC 优先级并从命令行添加到 OpenWithList

c++ - 为什么我的程序设计为耗尽 RAM 和 CPU 而没有使用所有 RAM 和 CPU?

c# - 是否可以在 Windows 7 和 Visual Studio 2012 中开发 Windows Mobile 应用程序

windows - 批量处理文件一个一个

windows - 隐藏一个简单的批处理窗口