Solved

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

Posted on 2016-07-19
7
198 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
[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 54

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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
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…

762 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