Windows XP Batch- IF EXIST FTP with Date Variable

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-29 09:22:08

问题


I am writing a quick batch to see if a file exists after executing an exe.

The file is created with a YYYYmmDDnumbernumbernumber.xml file name according to the current date.

How do I check for the file with a variable in the beginning? Here is what I have so far:

@echo off

set mydate=%date:~10,4%%date:~4,2%%date:~7,2%

if not exist "ftp://FTPsite/%mydate%*.xml" (echo nah) else (echo yea)

pause

回答1:


you cannot check existence of file on ftp server with IF.Instead try this after replacing the parameters that starts with MY_ :

!cls&echo off&setlocal ENABLEDELAYEDEXPANSION
!cls&goto :ftp_end
open MY_FTP_SERVER
user MY_USER
pass MY_PASS
cd MY_REMOTE_DIR
ls . local.file
bye
:ftp_end

ftp -s:%0
set mydate=%date:~10,4%%date:~4,2%%date:~7,2%
type local.file | findstr  /B "%mydate%" | find ".xml" && echo FILE IS OUT THERE && goto :skip_file_is_not_there
echo FILE IS NOT THERE
:skip_file_is_not_there
del local.file /q >nul


来源:https://stackoverflow.com/questions/16395133/windows-xp-batch-if-exist-ftp-with-date-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!