Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-07-19
7
Medium Priority
?
310 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
7 Comments
 
LVL 39

Accepted Solution

by:
BillDL earned 1000 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 59

Assisted Solution

by:Bill Prew
Bill Prew earned 500 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
Independent Software Vendors: 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!

 

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 44

Assisted Solution

by:Davis McCarn
Davis McCarn earned 500 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 44

Assisted Solution

by:Davis McCarn
Davis McCarn earned 500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

926 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