Page 1 of 1

Batch File -Date & Time

Posted: 24 Jun 2009 05:01
by guru_sanjay
Hi,

I want a batch file which will connect to an FTP server , get one DOC file and the downloaded DOC file should be renamed as Filename_Today's Date.doc format.

Please help me in creating a batch file for this.

Regards
Sanjay

Posted: 24 Jun 2009 08:50
by RElliott63
Here's a start .. might want to adjust due to regional settings for dates or others...

Code: Select all

Set "ftpFile=Script.ftp" 
Set "ftpIP=xxx.xxx.xxx.xxx"
Set "DD=%Date:~3,2%"       REM Get Day
Set "MM=%Date:~0,2%"       REM Get Month
Set "YY=%Date:~6,4%"       REM Get Year
Set "Today=%YY%%MM%%DD%"
Set "ToFile=%Today%.doc"

Echo UserID    > %ftpFile%
Echo Password >> %ftpFile%
Echo bin      >> %ftpFile%
Echo lcd Folder   >> %ftpFile%
Echo cd Folder    >> %ftpFile%
Echo Get OneDoc.File  >> %ftpFile%
Echo bye     >> %ftpFile%

start ftp -v -i -s:"%ftpFile%" %ftpIP%

If Exist OneDoc.file (
   Ren OneDoc.file %ToFile%
)