Need help with variables inside FTP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kessyus
Posts: 1
Joined: 03 Nov 2011 07:45

Need help with variables inside FTP

#1 Post by kessyus » 03 Nov 2011 07:56

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.

djangofan
Posts: 23
Joined: 04 Nov 2011 12:28

Re: Need help with variables inside FTP

#2 Post by djangofan » 04 Nov 2011 13:22

Its just a quick guess, but try this:

Code: Select all

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

Post Reply