COMMAND LINE FTP INSTRUCTIONS:

Command Line Ftp Tutorial:

Command Line Ftp Commands:

set          set one or more arguments

syntax:

set [--argument parameters] [--argument paramters]...

set arguments:

set --host www.mydomain.com --port 21 --username david --password mypass

with empty parameter to rest(clear) the filters:

set --include --exclude --lsize --gsize --lmodified --gmodified

connect      connect to remote server

syntax:

connect [--host host] [--port port]

example1:

connect --host www.mydomain.com --port 21

example2:

set --host 125.15.46.32 --port 21  
connect

login        login to remote server

syntax:

login [--username username] [--password password]

example1:

login --username david --password myPassword       

example2:

set --username david --password myPassword  
login

disconnect   terminate ftp session

syntax:

disconnect

quit         terminate ftp session and exit

syntax:

quit

get          receive one file

syntax:

get --src sourceFile [--dst destinationFile] [--image <true or false>] [--local localFolder]

save as a same name:

get --src "my customer.txt" --local "D:\My Documents\"

save as a different name :

get --src "my customer.txt" --dst MyCustomer.txt --local "D:\My Documents\"

put          send one file

syntax:

put --src sourceFile [--dst destinationFile] [--image <true or false>] [--local localFolder]

put the file on the server as a same name:

put --src myPicture.jpg --local "D:\My Documents\"

put the file on the server as a different name:

put --src myPicture.jpg --dst newPicture.jpg --local "D:\My Documents\"

dele         delete a file at remote

syntax:

dele --name file

example:

dele --name temp.doc

mget         get multiple files with optional filter

syntax:

mget [--justprint <true or false>] [--include wildcard|wildcard] [--exclude wildcard|wildcard] 
[--lsize KBs] [--gsize KBs] [--lmodified minutes] [--gmodified minutes] 
[--maxfiles number] [--maxfolders number] [--recurse <false or true>]...

print matched .doc files, but not actually download them:

mget --justprint true --include "*.doc" 

download .txt and .mp3 files, but exclude “private” folder:

mget --include "*.txt|*.mp3" --exclude "*/private/*" --recurse true

download .htm and .html files that modified within 15 minutes:

mget --lmodified 15 --include "*.htm|*.html"

mput         send multiple files with optional filter

syntax:

mput [--justprint <true or false>] [--include wildcard|wildcard] [--exclude wildcard|wildcard] 
[--lsize KBs] [--gsize KBs] [--lmodified minutes] [--gmodified minutes] 
[--maxfiles number] [--maxfolders number] [--recurse <false or true>]...

print matched .txt files, but not actually upload them:

mput --justprint true --include "*.txt" 

upload .txt and .mp3 and .doc files, but exclude “private” folder:

mput --include "*.txt|*.mp3|*.doc" --exclude "*\private\*" --recurse true

upload .htm and .html files that modified more than 1 hour (60 minutes) ago:

mput --gmodified 60 --include "*.htm|*.html"

mdele        dele multiple files with optional filter

syntax:

mdele [--justprint <true or false>] [--include wildcard|wildcard] [--exclude wildcard|wildcard] 
[--lsize KBs] [--gsize KBs] [--lmodified minutes] [--gmodified minutes] 
[--maxfiles number] [--maxfolders number] [--recurse <false or true>]...

print all files, but not actually delete them:

mdele --justprint true --include "*" 

delete .temp and .tmp files, exclude “private” folder:

mdele --include "*.temp|*.tmp" --exclude "*/private/*" --recurse true

delete .htm and .html files that file size less than 15 KB:

mdele --lsize 15 --include "*.htm|*.html"

literal      send arbitrary ftp command

syntax:

literal --name command --expresp <expected response code>

send a command to FTP server:

literal --name SYST --expresp 2

send a command with argument:

literal --name "MKD TEST" --expresp 2

list         list contents of remote directory

syntax:

list [--name directory]

list contents of current directory:

list

list contents of specified directory:

list --name /home/dirname

nlst         list file names of remote directory

syntax:

nlst [--name directory]

list contents of current directory:

nlst

list contents of specified direstory:

nlst --name /home/dirname

mkd          create a directory at server

syntax:

mkd --name directory  

example:

mkd --name testdir

pwd          print working directory on remote machine

syntax:

pwd

rename       renames the remote file src to dst

syntax:

rename --src source --dst destination

example:

rename --src myfile.doc --dst work.doc

rmd          remove directory on the remote machine

syntax:

rmd --name directory [--recurse <true or false>] [--justprint <true or false>]

remove empty directory:

rmd --name tempdir --recurse false

just print all matched files and folders, but not actually delete them:

rmd --name "test dir" --recurse true --justprint true

remove directory and all sub-directories(be careful!):

rmd --name "test dir" --recurse true --justprint false

size         determine the size of a remote file

syntax:

size --name file

example:

size --name myfile.exe

mdtm         determine the modification date of a remote file

syntax:

mdtm --name file

example:

mdtm --name myfile.exe

syst         print the remote system type. e.g. UNIX

syntax:

syst

cwd          change path at remote

syntax:

cwd --name directory

example:

cwd --name newDirectory

cdup         move to parent directory at remote

syntax:

cdup

response     print the last response received

syntax:

response

home         open web browser on home page

syntax:

home

man          open web browser on manual page

syntax:

man

log          open FTP log file

syntax:

log

@cmdfile     read commands from @textfile

syntax:

@cmdfile

call from any software:

CmdFtp @mycmdfile.txt

call from any software(full path):

CmdFtp "@D:\my path\mycmdfile.txt"

Interactive:

 CmdFtp> @mycmdfile.txt

Interactive(full path):

 CmdFtp> "@D:\my path\mycmdfile.txt"

status       show current status and parameters for debug

syntax:

status

help         print local help information

syntax:

help

Command Line Ftp Arguments:

host         host name or ip address

syntax:

--host host

example1:

--host www.mydomain.com

example2:

--host 215.37.25.15

port         port number, default 21

syntax:

--port port

example:

--port 21

username     FTP login username

syntax:

--username yourUsername

example:

--username david

password     FTP login password

syntax:

--password yourPassword

example:

--password myPassword

remote       specify the remote folder for FTP transfer

syntax:

--remote folder

example:

--remote "/home/david/public_html/"

local        specify the local folder for FTP transfer

syntax:

--local folder

example:

--local "D:\My Documents\"

passive      use Passive or Active FTP

syntax:

--passive <true or false>

Use Passive FTP(default):

--passive true

Use Active FTP:

--passive false

overwrite    overwrite an exisiting file?

syntax:

--overwrite false or true

replaces destination regardless of its size(default):

--overwrite true

replaces destination when size different:

--overwrite false

image        specified the Image(default) or ASCII transfer type

syntax:

--image <true or false>

Image(Binary) transfer type(default):

--image true

ASCII(Text) transfer type:

--image false

recurse      recursive through subdirectories ?

syntax:

--recurse <false or true>

recurse through subdirectories:

--recurse true

disable recurse scan(default):

--recurse false

include      wildcard path include filter, separated by |

syntax:

--include filter|filter

transfer .doc and .jpg files:

--include "*.doc|*.jpg"

transfer all files:

--include "*"

transfer one file that named “love.mp3”:

--include "*love.mp3"    

empty parameter to clear filter :

--include

exclude      wildcard path exclude filter, separated by |

syntax:

--exclude filter|filter

exclude .doc and .jpg files:

--exclude "*.doc|*.jpg"

exclude one file that named dirty.exe:

--exclude dirty.exe    

empty parameter to clear the filter:

--exclude

lsize        transfer the files size less than Num KB

syntax:

--lsize number

transfer the files less than 1MB(1024KB):

--lsize 1024

empty parameter to clear the filter:

--lsize

gsize        transfer the file large than Num KB

syntax:

--gsize number

transfer the files large than 100KB:

--gsize 100

empty parameter to clear the filter:

--gsize

lmodified    transfer the files modified within Num minutes

syntax:

--lmodified number

transfer the files modified within 30 minutes:

--lmodified 30

empty parameter to clear the filter:

--lmodified

gmodified    transfer the files modified more than Num minutes ago

syntax:

--gmodified number

transfer the files modified more than 1 day (1440 minutes) ago:

--gmodified 1440

empty parameter to clear the filter:

--gmodified

maxfiles     Specifies the maximum number of files to find.

syntax:

--maxfiles number

example:

--maxfiles 10

empty parameter to clear the filter:

--maxfiles

maxfolders   Specifies the maximum number of folders to find.

syntax:

--maxfolders number

example:

--maxfolders 10

empty parameter to clear the filter:

--maxfolders

name         specify a name

syntax:

--name name

example1:

--name "my pic.jpg"

example2:

--name myPic.jpg

src          specify source name

syntax:

--src source

dst          specify destination name

syntax:

--dst destination

justprint    print all matched files, but not actually transfer them

syntax:

--justprint <false or true>

example:

--justprint true

keepalive    maintain an active connection(default 30 seconds)

syntax:

--keepalive <interval seconds to sending a command>

disable keep alive:

--keepalive -1

every 40 seconds to sending a command to server to maintain an active connection:

--keepalive 40

debug        how much information they should display?

syntax:

--debug [0,1,2,3]

disable debug information:

--debug 0

displays help information:

--debug 1

displays all responses received from the server:

--debug 2

displays all commands sent to the server:

--debug 3

expresp      expected response code for literal, default 2

syntax:

--expresp num

encoding    choose the encoding of ftp server

syntax:

--encoding <codepage>

the ansi code page(default):

--encoding 0

UTF-8 translation(auto detected):

--encoding 65001

Russian:

--encoding 1251

Japanese:

--encoding 932

Simplified Chinese:

--encoding 936

http://msdn.microsoft.com/en-us/goglobal/bb964653.aspx


compress    compress files to ZIP for uploads

syntax:

--compress <filename.zip>

example:

--compress files.zip

Ftp Command Line Tutorial examples

Connecting

To connect, first run command line ftp to open a command prompt . At the prompt type connect --host ftp.mysite.com --port 21 When connected, type login --username yourusername --password yourpassword, be sure enter the username and password according to which lockers your wish to access. When loggedin, you are ready to transfer files!


Changing directories

By default any downloaded files will be put in the directory you started ftp from. To change directories prior to running ftp, type cwd --name directoryname at the prompt. To change directories on your local system after running ftp, type set --local directoryname at the CmdFtp> prompt.

You may also wish to change directories on the server, to download files in a subfolder or to upload files to the incoming folder. To do so simply type cwd --name directoryname at the CmdFtp> prompt.


Downloading files

The get command is the key to downloading files. If you know the name of the file to download, simply type get --src filename and the file will be placed on your local hard-drive. If unsure of the file name, type list to get a listing of available files.

The mget command is the key to downloading multi-files with filters. set --justprint true to print all matched files, then set --justprint false to actually download them.

connect --host ftp.gamerz.net --port 21 
login --username anonymous --password anonymous@anonymous       
cwd --name pub  
get --src aps.tar --local "D:\testdownload" --image false
#download .c and .pl files that file size less than 7 KB
mget --include "*.c|*.pl" --lsize 7

command line ftp download


Uploading files

The complement to get is the put command. If you know the name of the file you want to upload, simply type put --src filename and the file will be placed on the ftp server. To put the file on the server as a different name, type put --src filename --dst newname.

Windows Command Line Ftp Batch file

first, create a text file contains commands and save to the software install folder, each line is identified by a line feed or carriage return and line feed combination.

Lines that start with ‘#’ or that are completely blank are comments.

  1. run command from CmdFtp> prompt:

     CmdFtp> @cmdfile.txt
    
    or full path:
    CmdFtp> "@D:\my path\cmdfile.txt"
    
  2. call from any software:

     CmdFtp.exe "@D:\my path\cmdfile.txt"
    

read ftp commands from text file


Ftp Command Line Example

Please Note: Parameters that include spaces must be enclosed in quotes

your can save the commands bellow to connect.txt in software install folder.

connect --host ftp.mydomain.com --port 21  --local "D:\testdownload"
login --username myname --password mypass       
cwd --name dirname  

download one file:

@connect.txt
get --src myfile.txt --dst newfile.txt --image false

download .exe and .zip, exclude temp folder, skip if file exists with same size:

@connect.txt
mget --include "*.exe|*.zip" --exclude "*/temp/*" --recurse true --overwrite false

upload all files that modified within 30 minutes:

@connect.txt
#reset the include and exclude filter, change local folder
set --include --exclude --local "D:\My Document\doc\"
#upload all files that modified within 30 minutes
mput --lmodified 30 --recurse false

recurse delete all .temp and .tmp files then disconnect:

@connext.txt
mdele --include "*.tmp|*.temp" --recurse true
#done
disconnect

download files that size less than 100 MB (102400KB) and modified within 6 hours (360 minutes):

#recurse download .avi, .mpg and .mp3 from movies folder at remote
set --host www.newsite.com --username david --password ArbItriry
set --recurse true --local "D:\movies\" --remote movies --passive false 
set --include "*.avi|*.mpg|*.mp3" --overwrite false --recurse true
mget --lsize 102400 --lmodified 360
#done
quit

remove an empty directory

#be sure recurse false
rmd --name dirname --recurse false

executing the rmd command through a directory hierarchy

#this option can be very useful while at the same time extremely dangerous.
#enable justprint to view the matched files
rmd --name dirname --recurse true --justprint true
#excuting rmd now
rmd --name dirname --recurse true --justprint false

compress files to ZIP for uploads(put)

#compress D:\movies\tutorial.avi to tutorial.zip, 
#and upload it to /home/david/movies/tutorial.zip
set --host www.newsite.com --username david --password ArbItriry
set --recurse false --local "D:\movies\" --remote /home/david/movies --passive false    
put --src tutorial.avi --compress tutorial.zip --overwrite false    
quit

compress files to ZIP for uploads(mput)

#compress HTML files that modified within 5 minutes to htmls.zip
#and upload it to /home/david/public_html/htmls.zip
set --host www.mysite.com --username david --password ArbItriry
set --recurse true --local "D:\website\" --remote /home/david/public_html
set --include "*.html|*.htm|" --lmodified 5 
mput --compress htmls.zip --overwrite true  
quit

Wildcard include and exclude filter syntax

You can include this option several times ( separated by | ) to specify specific patterns which are to be included in the file path. Once you specify one pattern you exclude all files not matching at least one of the patterns. The case be useful for restricting the types of files to be backup.

* Matches 0 or more instances of any character.
For example, setting for *comp*.txt finds .txt files name containing any word starting with the letters comp, such as computer, company, or comptroller.
? Matches exactly one instances of any character.
For example, setting for *t?p* matches any of the files path include tap, tip, and top.
[chars] Matches one instance of any character that appears between the brackets.
[!chars] Matches one instance of any character that does not appear
between the brackets after the exclamation mark.
| Separator

Buy Now !!! Click to Automatically Apply for a 30% Discount Coupon Code for EasiestSoft

Download It ( for Windows 10, Win 8, Win 7, Vista, XP )


comments powered by Disqus

Best Command Line Ftp Client for Windows to batch ftp upload or ftp download from Windows Command line prompt.

Batch Ftp Software can pull commands from a text file, wildcard expansion allows the lcoal or remote file to be included or excluded in the command….
Read More about Command Line Ftp >>

SCREENSHOT:

 screenshot