问题描述
所有,需要在批处理文件的脚本一个HLEP。我非常新的脚本。
我有它创建了一个名为FINANCE20141011.txt文件夹中的文件的ETL作业。我需要创建一个批处理文件,该文件会发现目前的日子文件,该文件是FINANCE20141011.txt(当前日期是2014年11月10日和文件发送到SFTP服务器。
有将是文件夹,例如,FINANCE20141009.txt,FINANCE20141008.txt在多个文件中。但脚本应该拉涨目前的日子文件。任何帮助。
感谢。
@回响
致电:GetDate.Init
REM:GetDate.Init应该叫在code一次性调用之前:GETDATE
致电:GETDATE
集资金= FINANCE%,比去年%% %%月一天%.TXT
回声%财政%
转到:EOF:GetDate.Init
设置/ A一月= 1,二月= 2,月= 3,四月= 4,可= 5,君= 6月= 7月= 8,月= 9,十月= 10,11月= 11,赤纬12
设置/ A星期一= 1,星期二= 2,星期三= 3,星期四= 4,周五= 5,坐= 6,太阳= 7
(
回声。设置InfHeader =
回声。设置InfSectionOrder =
回声。设置InfFooter =2 %%
回声。设置InfFooter1 =
回声。设置InfFooter2 =
回声。设置InfFooter3 =
回声。设置InfFooter4 =
回声。设置柜=OFF
回声。设置的COM preSS =OFF
回波。设置DoNotCopyFiles =ON
回声。设置RptFileName =NUL
)>中的%Temp%\\〜foo.ddf
转到:EOF:GETDATE
设置TF =%TEMP%\\〜%随机%
找到MakeCab / D InfFileName =%TF%/ F的%Temp%\\〜foo.ddf> NUL
FOR / F令牌有usebackq 1-7 = = delims:%% a。在(%TF%),DO(
设置/ A一年= %%克,一个月= %% B,天= 1 %% C-100,平日= %%一个
设置/ A小时= 1 %% D-100分钟= 1 %%的E-100,第二= 1 %% F-100)
删除%TF%> NUL 2 - ;&放大器; 1
转到:EOF
All, need a hlep in scripting in with batch file. I am very much new to scripting.
I have an etl job which creates a file in a folder named as FINANCE20141011.txt. I need to create a batch file which will find current days file which is FINANCE20141011.txt (current date is 11/10/2014 and send the file to sftp server.
There would be multiple file in the folder such as, FINANCE20141009.txt, FINANCE20141008.txt. But the script should pull up the current days file. Any help.
Thanks.
@Echo Off
Call :GetDate.Init
Rem :GetDate.Init should be called one time in the code before call to :Getdate
Call :GetDate
set finance=FINANCE%year%%month%%day%.txt
echo %finance%
Goto :EOF
:GetDate.Init
Set /A "jan=1,feb=2,mar=3,apr=4,may=5,jun=6,jul=7,aug=8,sep=9,oct=10,nov=11,dec=12"
Set /A "mon=1,tue=2,wed=3,thu=4,fri=5,sat=6,sun=7"
(
Echo .Set InfHeader=""
Echo .Set InfSectionOrder=""
Echo .Set InfFooter="%%2"
Echo .Set InfFooter1=""
Echo .Set InfFooter2=""
Echo .Set InfFooter3=""
Echo .Set InfFooter4=""
Echo .Set Cabinet="OFF"
Echo .Set Compress="OFF"
Echo .Set DoNotCopyFiles="ON"
Echo .Set RptFileName="NUL"
) >"%Temp%\~foo.ddf"
Goto :Eof
:GetDate
Set "tf=%Temp%\~%random%"
Makecab /D InfFileName="%tf%" /F "%Temp%\~foo.ddf" >NUL
For /F "usebackq tokens=1-7 delims=: " %%a In ("%tf%") Do (
Set /A "year=%%g,month=%%b,day=1%%c-100,weekday=%%a"
Set /A "hour=1%%d-100,minute=1%%e-100,second=1%%f-100")
Del "%tf%" >NUL 2>&1
Goto :Eof
这篇关于与当前日期批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!