MahargNala
asked on
Get CSV file via ftp with todays date via a batch file
I am trying to extract a file that gets generated on our system each day via a batch file, the file is a CSV file. I need to GET the file via FTP, the file name will have today's date in each day, so for example if the file was run through on the 15th June 2010 the format of the file name must be 150610.CSV
Can anyone please help me with this dilema I am having as can not get it anything to work.
Thanks
Can anyone please help me with this dilema I am having as can not get it anything to work.
Thanks
If you can use powershell, I can help you out as it has an FTP module.
OK. To get the date in the right format you can follow the instructions in my article here to get the components of the date:
https://www.experts-exchange.com/articles/OS/Microsoft_Operating_Systems/MS_DOS/Using-dates-in-batch-files-scripts.html
Then you can use an ftp script like the ones I have here. The easiest is to use "method 3" from this page since you can then use the variable you set to the date in the script easily.
http://scripts.dragon-it.co.uk/links/batch-ftp-scripting
Can elaborate more if you want me to.
Steve
https://www.experts-exchange.com/articles/OS/Microsoft_Operating_Systems/MS_DOS/Using-dates-in-batch-files-scripts.html
Then you can use an ftp script like the ones I have here. The easiest is to use "method 3" from this page since you can then use the variable you set to the date in the script easily.
http://scripts.dragon-it.co.uk/links/batch-ftp-scripting
Can elaborate more if you want me to.
Steve
Essentially, you supply a script file, and then a calling batch file:The script file would have something like:open ftp.mysite.comuserguestguestlcd c:\DownloadFoldercd UploadFolderbinaryget %1quit The batch file could have something like: @echo off set filename=%date:~3,2%%date: ~0,2%%date :~-2%.CSV ftp -i -s:c:\scripts\myFTPFile.sc r %filename%Some good FTP script sites: http://www.robvanderwoude.com/ftp.php http://support.microsoft.com/kb/96269
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry sirbounty hadn't refreshed and seen your example. I tend to shy away from using %date:...% only because of differences of date formats for different users, scheduled tasks, different OS computers etc. but if it works for the specific situation fine!
That was all one script above btw, the second @Echo off can be removed.
Steve
That was all one script above btw, the second @Echo off can be removed.
Steve
ASKER
I found this solution the easiest to follow and got my files extracted within moments.
No proiblem, glad it helped.
Steve
Steve