删除本地驱动器上的文件上传成功后,使用批处理文件到FTP [英] delete a file from local drive after successful upload to ftp using batch file

查看:470
本文介绍了删除本地驱动器上的文件上传成功后,使用批处理文件到FTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要成功发送后,从我的本地系统中删除文件使用批处理文件到FTP。调度目的I M使用窗口调度。下面是我的code,它能够张贴到ftp.how删除成功发送到FTP文件,否则不SHLD删除。

i want to delete file from my local system after successful send to ftp using batch file. for scheduling purpose i m using window scheduler. below is my code which is able to post to ftp.how to delete that successful send to ftp otherwise file shld not delete.

 %windir%\system32\ftp.exe -s:%~f0
 goto done
 cd C:\
 open Host Name
 user_name
 password
 bi
 put user_input.csv
 bye
 :done
 @echo off
 cls
 exit 

如果我会写在这里删除它,然后会删除远程server.pls建议我该怎么做,使用窗口Ftp.exe的

if i will write delete here then it ll delete from remote server.pls suggest me how to do that using window ftp.exe

推荐答案

您需要重定向FTP命令的输出。检查是否有成功的消息,并且在采取行动。

You need to redirect the output of the FTP command. Check for a succesful message and act upon it.

我不能提供一个确切的剧本,因为这将取决于你实际使用FTP命令,但这个想法是这样的。

I can't provide an exact script, because it will depend on the FTP command you actually use, but the idea is like this.

echo open Host Name >%temp%\ftpin.txt
echo user_name >>%temp%\ftpin.txt
echo password >>%temp%\ftpin.txt
echo put user_input.csv >>%temp%\ftpin.txt
echo bye  >>%temp%\ftpin.txt
ftp -n -s:%temp%\ftpin.txt >%temp%\ftpout.txt
for /f "tokens=* skip=9" %%a in (ftpout.txt) do (
   if "%%a"=="226 Transfer complete." (
   del user_input.csv
   )
)

修改:您将有你的蝙蝠调整到你的FTP脚本的实际输出。也许你将需要更改命令跳过参数。

EDIT: You will have to adjust your BAT to the actual output of your FTP script. Probably you will need to change the "skip" parameter of the FOR command.

这篇关于删除本地驱动器上的文件上传成功后,使用批处理文件到FTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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