Windows批处理脚本在调用文件时选择周数

时间:2014-04-03 15:33:15

标签: batch-file ssis

我考虑在我的SSIS包中加入一个批处理文件,通过winscp.com将文件放入SFTP站点,因此需要在最后编写一个批处理文件,将所需文件放入SFTP站点,我已经编写了下面的过程,但是我需要帮助来调用看起来像Filename_Week#的文件(例如Filename_1,文件名_2 ... Filename_34)并且位于M:\ Test \ DATA OUT文件夹中。我的感觉是在设置v_week =%1之后添加一个if语句(即如果[%v_week%] == [] SET v_week = week#),但我不确定那是什么,因为我从未写过批处理文件之前。

SET v_week=%1
echo option batch continue > SFTP_Filename_Put.txt
echo option confirm off >> SFTP_Filename_Put.txt
echo open target >> SFTP_Filename_Put.txt
echo lcd "M:\Test\DATA OUT" >> SFTP_Filename_Put.txt
echo cd / >> SFTP_Filename_Put.txt
echo put "M:\Test\DATA OUT\Filename_%v_week%.txt" /Filename_%v_week%.txt >> SFTP_Filename_Put.txt
echo exit >> SFTP_Filename_Put.txt
M:\temp\apps\WinSCP\winscp.com/script="M:\Development\SFTPBatchFiles\SFTP_Filename_Put.txt"
del SFTP_Filename_Put.txt

1 个答案:

答案 0 :(得分:0)

像这样,它会自动获取最后创建的.fyi文件并获取最后2个字符 并设置V_week变量。

@echo off&cls
setlocal EnableDelayedExpansion
for %%a in (*.fyi) do set $WeekNb=%%~na
set $WeekNb=%$WeekNb:~-2%

set v_week=%$WeekNB%

echo The Week Number Is : %v_week%

pause