Link to home
Start Free TrialLog in
Avatar of mcs26
mcs26

asked on

MS DOS File Loop FTP

Hi,

I have no DOS knowledge. What I am trying to do is to copy a file from an FTP site to my local computer. I already have this code however the problem is that the file name that I wish to copy from our data provider has a different & random number assigned to it every day.

Below is an example of two files names. It is the first number that is casuing me problems.

41936811_TAPLATRI_20100420_Global_Barcap_HY_Index.csv
41552871_TAPLATRI_20100419_Global_Barcap_HY_Index.csv

So what I thougt would be the best thing to do is to loop through the folder and using a bit of string manipluation find the file which contains the name "TAPLATRI" (there is only one file with this name) then copy it to my local computer. However like I have said I have no DOS knowledge and am not sure how to do this?

My Bactch File
G:
G:\Shared\Mark\Scheduled Tasks

ftp -s:txtLehman.scp indexftp.barcap.com

My Text File
username
password

prompt n
cd point
cd download

get 41936811_TAPLATRI_20100420_Global_Barcap_HY_Index.csv "G:\Shared\Mark\FTP\TAPLATRI_20100420_Global_Barcap_HY_Index.csv" overwrite

quit




Thanks for any help,

Mark



username
password

prompt n
cd point
cd download

get 41936811_TAPLATRI_20100420_Global_Barcap_HY_Index.csv "G:\Shared\Mark\FTP\TAPLATRI_20100420_Global_Barcap_HY_Index.csv" overwrite 

quit

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcs26
mcs26

ASKER

Hi woolmilkporc,

Thanks replying thats perfect! One thing I forgot to mention was the file name is RandomNumber_TAPLATRI_yyyymmdd_rest. So today I need the file name TAPLATRI_20100426 How would I do that?

Thanks
Well, try
mget *_TAPLATRI_*_Global_Barcap_HY_Index.csv  
Should work!
Avatar of mcs26

ASKER

Its works but it downloads all the old TAPLATRI files, I only want it to copy todays file over?
At the top of your batch file, add

FOR /F “TOKENS=1* DELIMS= ” %%A IN (’DATE/T’) DO SET CDATE=%%B
FOR /F “TOKENS=1,2 eol=/ DELIMS=/ ” %%A IN (’DATE/T’) DO SET mm=%%B
FOR /F “TOKENS=1,2 DELIMS=/ eol=/” %%A IN (’echo %CDATE%’) DO SET dd=%%B
FOR /F “TOKENS=2,3 DELIMS=/ ” %%A IN (’echo %CDATE%’) DO SET yyyy=%%B
SET mydate=%yyyy%%mm%%dd%

get %_TAPLATRI_%mydate%_Global_Barcap_HY_Index.csv "G:\Shared\Mark\FTP\" overwrite
Oops... sorry got the get command wrong.
Use mcs26's, i.e.

mget *_TAPLATRI_%mydate%_Global_Barcap_HY_Index.csv "G:\Shared\Mark\FTP\" overwrite
Avatar of mcs26

ASKER

Hi Cyber Kiwi,

Thanks for replying. Am i supposed to put all the FOR commands into my text file or batch file?. If I put it at the top of my batch file it does not execute?

Thanks