批处理文件,用于检查FTP文件夹是否存在与掩码匹配的任何文件 [英] Batch file that checks FTP folder if any file matching a mask exist
本文介绍了批处理文件,用于检查FTP文件夹是否存在与掩码匹配的任何文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个到受保护的FTP站点的批处理文件,检查是否存在文件类型( *。txt
),如果存在,请继续下一步,如果没有,返回0并结束工作。
I need to create a batch file that goes to a protected FTP site, checks if a file type (*.txt
) exists, and if it does, proceed to the next step, if not, return a 0 and end the job.
我做了大量搜索,找不到任何解决方案。
I've done extensive searching and couldn't find any solutions.
推荐答案
这不是一项简单的任务,特别是如果您需要检查与掩码匹配的文件(不适用于特定文件)。
It's not a trivial task, particularly if you need to check for a file matching a mask (not for a specific file).
您可以使用 WinSCP脚本:
@echo off
set REMOTE_PATH=/home/user/*.txt
winscp.com /command ^
"open ftp://user:password@host/" ^
"option failonnomatch on" ^
"ls %REMOTE_PATH%" ^
"exit"
if %ERRORLEVEL% neq 0 goto error
echo File(s) matching %REMOTE_PATH% exist
rem Do something
exit 0
:error
echo Error or no file matching %REMOTE_PATH% exists
exit 1
上面的代码来自WinSCP关于检查文件是否存在。
The above code is from the WinSCP article on Checking file existence.
(我是WinSCP的作者)
这篇关于批处理文件,用于检查FTP文件夹是否存在与掩码匹配的任何文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文