Solved

How to download entire directory with specific files in it via ftp command

Posted on 2016-07-19
7
174 Views
Last Modified: 2016-08-16
Hi,

I want to download entire directory from FTP site with specific files in it via FTP command. Here's the scenario.
1. There can be multiple folder and sub folder in directory. Files are stored in the folder
2. there can be multiple files in folder with different name. The requirement is to download files starts with certain character.

For ex.
Directory has 3 folders and subfolder and files as  listed below. each subolder has 3 files with different name (There can be multiple files)
1. Folder 1 -> Sub Folder 1 ->  abc.txt, abd.txt, zyc.txt
2. Folder 2 -> Sub Folder 1 ->  abf.txt, abi.txt, zyt.txt
3. Folder 3 -> Sub Folder 1 ->  abt.txt, abp.txt, zyd.txt

I need to download above directory with all of the folder, but files needs to be download which starts with "ab" only.

Currently I'm using following FTP command which download all the folder and files.

set "coreFtpPath=C:\Program Files\CoreFTP"
set "coreFtpSiteName=test_ftp"

set "RemoteLocation1=/"

set "downloadLocation=C:\BatchFile\Files\Files"

coreftp.exe -s -O -site %coreFtpSiteName% -d %RemoteLocation1%  -p %downloadLocation% -log %Log% -output %LogOutput%


Please suggest as how can download files with specific name. Also, at the same time I need to download the entire directory with folder names and subfolders.
0
Comment
Question by:SHANCHAT972
7 Comments
 
LVL 38

Accepted Solution

by:
BillDL earned 250 total points
ID: 41720301
I looked to see what command line options coreftp supports, but sadly they seem to be limited:
http://www.coreftp.com/docs/web1/Command_Line_FTP.htm
https://blogs.msdn.microsoft.com/robert_mcmurray/2009/05/01/ftp-clients-part-6-core-ftp-le/

My first instinct would be to:

1. Use the built-in Windows FTP.exe command and accompanying script file to get a directory listing of the remote site (or part of it) to a text-based file on your computer using the DIR, MDIR, LS, MLS,
http://ss64.com/nt/ftp.html

2. From the command line, parse the saved directory listing file and use the FIND command (or FINDSTR) to filter the results to only the files you want to download.

3. Use the separate lines in the results to instruct coreftp (or other command line FTP program) to download each file in turn, either as part of a script file or issued as separate instructions.

Unless another expert can suggest an alternative command line FTP program with more helpful options, I think this might be the only way to achieve what you want.
0
 
LVL 53

Assisted Solution

by:Bill Prew
Bill Prew earned 125 total points
ID: 41721000
So is it true you want the effect of an XCOPY, just over FTP?  Meaning, you want to copy all files matching a pattern, looking in subfolders of the source, and copy them with the folder hierarchy to the destination?

~bp
0
 

Assisted Solution

by:SHANCHAT972
SHANCHAT972 earned 0 total points
ID: 41721909
@Bill Prew:  Yes, I want XCOPY feature FTP.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:SHANCHAT972
ID: 41721912
@BillDL: All folder and files are located in SFTP site, so i've to use the ftp command only. I'm not sure if i can use the dir and other windows command as part of ftp.

Do you have any working sample of suggestion that you've mentioned?
0
 
LVL 43

Assisted Solution

by:Davis McCarn
Davis McCarn earned 125 total points
ID: 41726540
Get yourself a copy of FTPDrive; its free: http://www.killprog.com/fdrve.html
Set it up to access the FTP site and it will become a drive letter which you can then use XCOPY, BAT files, or Explorer to do whatever you want.
0
 

Author Comment

by:SHANCHAT972
ID: 41752745
@Davis McCarn:  I don't want to include new component in my project as it involves installing/configuring the new component in Production environment as well. I'll dig more into to see alternate solution to achieve this without introducing new components.

Thanks for your help!
0
 
LVL 43

Assisted Solution

by:Davis McCarn
Davis McCarn earned 125 total points
ID: 41753694
It will be more difficult; but, using various FTP subcommands, you can script what you want into a file.
Look at the other FTP: commands referenced here:
https://technet.microsoft.com/en-us/library/bb490664.aspx
and read this for a way to get started:
http://stackoverflow.com/questions/5064408/copy-files-from-ftp-server-to-local-directory
1

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let’s list some of the technologies that enable smooth teleworking. 
For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question