Batch File -Date & Time

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
guru_sanjay
Posts: 2
Joined: 24 Jun 2009 04:57

Batch File -Date & Time

#1 Post by guru_sanjay » 24 Jun 2009 05:01

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

RElliott63
Expert
Posts: 80
Joined: 04 Feb 2009 10:03

#2 Post by RElliott63 » 24 Jun 2009 08:50

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%
)

Post Reply