Link to home
Start Free TrialLog in
Avatar of oconnork00
oconnork00Flag for United States of America

asked on

Upload all files and folders inside a folder via FTP

Hi there,

I'm trying to upload the entire contents of a folder called sms.
Inside this folder called sms are other files and folders.

My current solution is only uploading files that reside in /sms/files.txt but not /sms/folder/files.txt

So, I need to upload the entire content.

here's the batch script I'm using:

@echo off
set SourceFolder=C:\Users\Kevin\Desktop\temp\Restaurant\chans-restaurant\sms
set SourceMask=*.*
echo user MYUSERNAME> sms.dat
echo MYPASSWORD>> sms.dat
echo binary>> sms.dat
echo cd /public_html/>>sms.dat
echo cd Restaurant>>sms.dat
echo cd chans-restaurant>>sms.dat
for %%a in ("%SourceFolder%\%SourceMask%") do (
>>sms.dat echo put "%%~a"
)
echo quit>> sms.dat
ftp -n -s:sms.dat MYDOMAIN.com
del sms.dat

Open in new window



The sms folder resides inside "chans-restaurant" folder.

Thanks in advance for your help
Avatar of Bill Prew
Bill Prew

Do you want the folder structure preserved in the destination location, or all files in the same folder?

~bp
Avatar of oconnork00

ASKER

Hi Bill,
I want it preserved - that is whatever is in each respective folder will be the same at the destination
Also, have you looked at something like NCFTPPUT, it can do a whole directory structure transfer with a single command line, via the -R option.  Oh yeah, and it's free.

http://www.ncftp.com/ncftp/
http://www.ncftp.com/ncftp/doc/ncftpput.html

~bp
I'm building this into a software tool Im working on, and spitting out an output batch file is required so it shells out and runs it afterwatds. So, no outside tools can be used unfortunately.
Is it safe to assume the destination directories exist?

Also, what language are you constructing the "tool" in?

~bp
Yes, they exist - I am using ubot studio.

Im able to upload these individually, by just changing the directory and uploading everything *.* but would prefer an all in one solution.

Eitherway, the batch file is produced as it should look and works fine - just need some help with how to upload everything inside the folder - I mean everything, folders inside folders and files etc.

Cheers bp

Kevin
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial