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

mcs26Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
Couldn't a simple "mget" (=multiple get allowing wildcards) do the trick?
mget *_TAPLATRI_20100420_Global_Barcap_HY_Index.csv "G:\Shared\Mark\FTP\" overwrite
Since source and target filename are identical, I assume there is no need to specify the target filename, specifying the directory alone should be enough.
Not sure though ...
wmp
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcs26Author Commented:
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
0
woolmilkporcCommented:
Well, try
mget *_TAPLATRI_*_Global_Barcap_HY_Index.csv  
Should work!
0
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

mcs26Author Commented:
Its works but it downloads all the old TAPLATRI files, I only want it to copy todays file over?
0
cyberkiwiCommented:
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
0
cyberkiwiCommented:
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
0
mcs26Author Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
File Sharing Software

From novice to tech pro — start learning today.