Solved

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

Posted on 2016-07-19
7
239 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:Arikkan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 56

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:Arikkan
Arikkan earned 0 total points
ID: 41721909
@Bill Prew:  Yes, I want XCOPY feature FTP.
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

Author Comment

by:Arikkan
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:Arikkan
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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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