We help IT Professionals succeed at work.

MS DOS BATCH FTP File Date Help

Hi,

I have some code (at the bottom of post) however I cannot seem to use the mget command to return all files with the name containing BGCO, any ideas would be great?

Thanks

Mark

@echo off
(echo open data.ftse.com
echo user username password
echo prompt n 
echo cd data
echo cd gilts
echo cd gilts_constituents 
echo mget BGCO*csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\BGCO.csv" overwrite  
echo quit
) | ftp -n -i

Open in new window

Comment
Watch Question

Most Valuable Expert 2013
Top Expert 2013
Commented:
Hi again,
what are you trying to achieve with this line -
mget BGCO*csv "G:\Shared\Fixed Income\Sovereign\Mark\FTP\BGCO.csv" overwrite  
I must have overlooked in our previous case that it's "mget" and not "get".
"mget" doesn't allow for specifying a local destination - it will just transfer the files to the local current directory.
So your command is basically correct, just omit the target specification G:\.......
"overwrite" is also not allowed with "mget"!
You wrote >> the name containing BCGO .... << 
In your version the name must start with BCGO. To find this string anywhere in the name use *BCGO*
wmp

Author

Commented:
Hi again,

No I only just remebered the file name changes everyday so I thought I would try to use mget but could not it get it work. I have just tried the below I taking I'm still doing something wrong?

thanks

Mark

@echo off
(echo open data.ftse.com
echo user username password
echo prompt n
echo cd data
echo cd gilts
echo cd gilts_constituents
echo mget *BGCO*.csv
echo quit
) | ftp -n -i
Most Valuable Expert 2013
Top Expert 2013

Commented:
OK,
if there are actually any files in the remote directory data/gilts/gilts_constituents matching *BCGO*.csv
and if you're allowed to write to your current local directory all should be fine.

Author

Commented:
yeah the directory is fine and I am able to write to my local directory.
in the dos screen it says "mget BGCO1406.csv?"

But it does not copy the file?
Most Valuable Expert 2013
Top Expert 2013

Commented:
That's the usual interactive prompt - and this should not happen with "-i" !
It's due to the line "prompt n" in your script.
"-i" in "ftp -i ..." turns prompting off, and "prompt n" turns it on again... Silly but true!
So either remove "prompt n" or omit the "-i" flag of ftp.

Author

Commented:
Bingo! Great thanks thats solved it! I have one question left which I think is pretty straight forward but as you can probably tell I know nothing about DOS! I'll start a new question so if you want you can get some more point!

thanks

Mark