我已经在批处理文件下面创建了文件,以便使用服务器上的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
所以只需在mget
命令中使用您的变量:
set VAR=0009
ECHO get /home/backup/dump/*%VAR%* >> %1_tmp.srjd