使用FTP从目录中获取名称包含特定字符串的特定文件

问题描述 投票:1回答:1

我已经在批处理文件下面创建了文件,以便使用服务器上的ftp获取一些文件...现在,我需要使用mget从下面的目录中获取特定文件。并非该目录中的所有文件。而且我需要将其作为变量传递,而不是静态的。

mget / home / backup / dump /

示例

目录dump有文件

a_0509_kasjada.dump
a_0009_kaoi.dump
a_0033_msdhaa.dump
a_0579_qptcla.dump

我只想mget包含0009的文件名将其作为变量传递。

@ECHO OFF
TITLE %1 - Get Dumps backup

SET @FileDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%%time:~0,2%%time:~3,2%


:PING 
ping    %2   -n 1
IF %errorlevel% NEQ 0 goto :PING


REM --- Check directories existence
IF NOT EXIST "D:\Backup" MKDIR "D:\Backup" 
IF NOT EXIST "D:\Backup\%1\" MKDIR "D:\Backup\%1" 
IF NOT EXIST "D:\Backup\%1\%@FileDate%\" MKDIR "D:\Backup\%1\%@FileDate%"

ECHO open %2> %1_tmp.srjd
ECHO oracle>> %1_tmp.srjd
ECHO olAdmin>> %1_tmp.srjd
ECHO lcd "D:\Backup\%1\%@FileDate%">> %1_tmp.srjd
ECHO bin>> %1_tmp.srjd

ECHO mget /home/backup/dump/*.*>> %1_tmp.srjd

ECHO bye>> %1_tmp.srjd

REM --- Launch FTP and pass it the script
FTP -i -s:%1_tmp.srjd

REM --- Cleanup.
DEL %1_tmp.srjd

REM --- PAUSE
EXIT
windows batch-file download ftp
1个回答
0
投票

所以只需在mget命令中使用您的变量:

set VAR=0009

ECHO get /home/backup/dump/*%VAR%* >> %1_tmp.srjd
© www.soinside.com 2019 - 2024. All rights reserved.