如果存在任何匹配掩码的文件,则检查 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屋!
查看全文