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_Ba rcap_HY_In dex.csv
41552871_TAPLATRI_20100419 _Global_Ba rcap_HY_In dex.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_Ba rcap_HY_In dex.csv "G:\Shared\Mark\FTP\TAPLAT RI_2010042 0_Global_B arcap_HY_I ndex.csv" overwrite
quit
Thanks for any help,
Mark
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
41552871_TAPLATRI_20100419
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, try
mget *_TAPLATRI_*_Global_Barcap_HY_Index.cs v
Should work!
mget *_TAPLATRI_*_Global_Barcap_HY_Index.cs
Should work!
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
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
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
Use mcs26's, i.e.
mget *_TAPLATRI_%mydate%_Global
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
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
ASKER
Thanks replying thats perfect! One thing I forgot to mention was the file name is RandomNumber_TAPLATRI_yyyy
Thanks