Solved

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

Posted on 2016-07-19
  • Windows Batch
  • File Sharing Software
  • MS DOS
  • Networking
  • SSH / Telnet Software
  • +1
7
133 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 51

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 42

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 42

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Outsource Your Fax Infrastructure to the Cloud (And come out looking like an IT Hero!) Relative to the many demands on today’s IT teams, spending capital, time and resources to maintain physical fax servers and infrastructure is not a high priority.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now