Page 1 of 1

Need help with variables inside FTP

Posted: 03 Nov 2011 07:56
by kessyus
Hey guys!

I'm new on this forum and I'm really in need of a help with this command sintaxe to make a batch file.

I've a ftp server which saves daily a file with the name: "REPORT_DDMMYYYYHH.txt". Where DD is the day, MM is the month, YYYY is the year and HH is the hour that the file was made.

I've to download this file by a batch to another computer so I wrote this bat command:

set mydate=%date:~0,2%%date:~3,2%%date:~6,4%
set file=REPORT_%mydate%*.txt
open xxx.xxx.xxx.xxx
username
password
binary
hash
lcd "d:\"
mget %file%
y
bye
cls
exit

It doesn't work because it says that could not find the file "%file%". Plus when I type the command "echo %file%" it says that the command isn't valid. But when I try to type the same command outside the "ftp>" (I mean after I log off from the ftp connection) it says the real value which is: "REPORT_03112011*.txt".

How do I make the ftp understand that %file% is a variable and that I need to use its value on that mget command?

Thanks in advice.

Kessyus.

Re: Need help with variables inside FTP

Posted: 04 Nov 2011 13:22
by djangofan
Its just a quick guess, but try this:

Code: Select all

set file="REPORT_%mydate%*.txt"