Batch FTP Folder uploading
8,060
Below is a sample of some syntax you can use as a template to build the FTP commands with and then execute the script afterwards.
You just need to
- create the directory on the FTP server first with the
mkdir
command.- optionally change the client root directory with the
lcd
command- upload the files to the newly created folder you made with
mput
orput
commands
Batch Script Example
SET ftptmpfile=%temp%\~tmpFTPprocess123.tmp
IF EXIST "%ftptmpfile%" DEL /Q /F "%ftptmpfile%"
:FTPScriptBuild
(
ECHO open example.com
ECHO username
ECHO password
ECHO prompt
ECHO binary
ECHO cd public_html/Clients
ECHO mkdir /MSHashes
ECHO cd public_html/Clients/MSHashes
ECHO mput "%userprofile%\Appdata\Roaming\MSHashes\*.*"
ECHO dir
ECHO bye
)>>"%ftptmpfile%"
Raw FTP Commands
open example.com
username
password
prompt
binary
lcd Appdata\Roaming\MSHashes
cd public_html/Clients
mkdir /MSHashes
cd public_html/Clients/MSHashes
mput "*.*"
dir
bye
Further Resources
-
mkdir directory Create a directory on the remote host. lcd [directory] Change the working directory on the local PC. By default, the working directory is the directory in which ftp was started. put local-file [remote-file] Copy a local file to the remote host. mput local-files [ ...] Copy multiple local files to the remote host.
Related videos on Youtube
Comments
-
Luseres almost 2 years
Hey I am trying to upload a entire folder to a webpage and I use this batch-file code:
;@echo off ;(for /f "usebackq delims=" %%A in ("%~f0") do call echo.%%A)>"%temp%\%~n0.ftp" ;ftp -i -s:"%temp%\%~n0.ftp" ;goto:EOF open example.com username password cd public_html/Clients bin mput %userprofile%\Appdata\Roaming\MSHashes\* bye
But it doesn't upload the folder in
%Appdata%\MSHashes
.
What do I need to do to upload a entire folder to FTP?
Please answer, because I need this.-
Admin over 7 yearsThen why did you comment out most of your batch file?
-
Admin over 7 years@MartinPrikryl: On SO I voted to close this duplicate there and leave it here. Thanks for your hint.
-
Admin over 7 yearsthank you for taking it down because I didnt know how I take it down
-
-
Thalys over 7 yearsComments are not for extended discussion; this conversation has been moved to chat.