Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理文件中的动态每日日期_Batch File_Ftp - Fatal编程技术网

Batch file 批处理文件中的动态每日日期

Batch file 批处理文件中的动态每日日期,batch-file,ftp,Batch File,Ftp,在下面的批处理文件中,日期为2015_01_21是ftp上按日期命名的文件夹,csv文件的名称中也有日期 如果我必须每天通过任务计划程序运行此批处理文件,如何自动更改此文件 ftp.exe -s:%0 open 111.11.111.11 Username Password get Samle/2015_01_21/Samle_AB20150121.csv.gz get Samle/2015_01_21_ABCD/Samle_AB210115.csv.gz quit 有

在下面的批处理文件中,日期为2015_01_21是ftp上按日期命名的文件夹,csv文件的名称中也有日期

如果我必须每天通过任务计划程序运行此批处理文件,如何自动更改此文件

ftp.exe -s:%0   
open 111.11.111.11   
Username  
Password

get Samle/2015_01_21/Samle_AB20150121.csv.gz  
get Samle/2015_01_21_ABCD/Samle_AB210115.csv.gz

quit
有关更多信息,请查看

@echo关闭
pushd“%temp%”
makecab/D RptFileName=~.rpt/D InfFileName=~.inf/f nul>nul

要使('find/i“makecab”^中的/f“tokens=3-7”%%a随日期动态变化,最好将临时文件传递到ftp,而不是传递bat本身。请尝试此方法

@echo off
setlocal
for /f "skip=1 tokens=1-3" %%a in ('WMIC PATH win32_localtime get day^,month^,year') do  (
    if "%%a" neq "" (
        set day=%a
        set month=%b
        set year=%c
    )
)

set ftpfile=%tmp%\ftpfile.txt

echo open 111.11.111.11>%ftpfile%
echo Username>>%ftpfile%
echo Password>>%ftpfile%

echo get Samle/%year%_%month%_%day%/Samle_AB%year%%month%%day%.csv.gz>>%ftpfile%
echo get Samle/%year%_%month%_%day%_ABCD/Samle_AB%day%%month%%year:~-2%.csv.gz>>%ftpfile%

echo quit>>%ftpfile%

ftp.exe -s:%ftpfile%
del %ftpfile%

那么你想自动更改日期?
@echo off
setlocal
for /f "skip=1 tokens=1-3" %%a in ('WMIC PATH win32_localtime get day^,month^,year') do  (
    if "%%a" neq "" (
        set day=%a
        set month=%b
        set year=%c
    )
)

set ftpfile=%tmp%\ftpfile.txt

echo open 111.11.111.11>%ftpfile%
echo Username>>%ftpfile%
echo Password>>%ftpfile%

echo get Samle/%year%_%month%_%day%/Samle_AB%year%%month%%day%.csv.gz>>%ftpfile%
echo get Samle/%year%_%month%_%day%_ABCD/Samle_AB%day%%month%%year:~-2%.csv.gz>>%ftpfile%

echo quit>>%ftpfile%

ftp.exe -s:%ftpfile%
del %ftpfile%