I have this script in a batch file that uploads a local file to our FTP server. I need to rename myfile.csv
to suffix the date and time in this format YYYYMMDDHHMM
e.g. myfile_201701041333.csv
. How can this be done?
@Echo Off
Set _FTPServerName=myserver
Set _UserName=myusername
Set _Password=mypassword
Set _LocalFolder=\\data\myfolder
Set _RemoteFolder=e-download
Set _Filename=myfile.csv
Set _ScriptFile=ftp1
:: Create script
>"%_ScriptFile%" Echo open %_FTPServerName%
>>"%_ScriptFile%" Echo %_UserName%
>>"%_ScriptFile%" Echo %_Password%
>>"%_ScriptFile%" Echo lcd %_LocalFolder%
>>"%_ScriptFile%" Echo cd %_RemoteFolder%
>>"%_ScriptFile%" Echo binary
>>"%_ScriptFile%" Echo put %_Filename%
>>"%_ScriptFile%" Echo quit
:: Run script
ftp -s:"%_ScriptFile%"
Del "%_ScriptFile%"