Using a DOS BAT file to do some heavy FTP work.
Ever wanted to upload a file automatically using Windows / DOS and FTP to your server. Its not that easy at all. Here is a bat file you can create to help automate this process. You can modify the file as you need and make different solutions for different problems.
Essentially this system saves a whole lot of commands to a file called ftpcmd.dat, then right at the end, you can get the inbuilt windows FTP client to execute this file. So here goes.
——————
@echo off
echo user USERNAME> ftpcmd.dat
echo PASSWORD» ftpcmd.dat
echo bin» ftpcmd.dat
echo cd DIRECTORY»ftpcmd.dat
echo put FILENAME» ftpcmd.dat
echo quit» ftpcmd.dat
ftp -n -s:ftpcmd.dat FTP.YOURSERVER.COM
del ftpcmd.dat
——————
Where USERNAME is your username.
PASSWORD your ftp passwrod.
DIRECTORY is a folder on your server, eg / for root, /sites/yoursite.com/images/ would be your images folder.
FILENAME is the file you want to copy, maybe you can do *.* or *.jpg and probably file1.jpg file2.jpg (havent tried that).
then FTP.YOURSERVER.COM is the ftp location of your server.
If you wanted to do more than 1 file or folder, then do something like this in the middle.
1.
echo cd DIRECTORY»ftpcmd.dat
echo put FILENAME» ftpcmd.dat
echo cd images/jpgs»ftpcmd.dat
echo lcd images/jpgs»ftpcmd.dat
echo put JPGFILES» ftpcmd.datThe LCD command means change my local computers directory. CD is change the directory I will upload into on the server.
2. If you want to command line this to make it even more flexible. @echo off
echo user USERNAME> ftpcmd.dat
echo PASSWORD» ftpcmd.dat
echo bin» ftpcmd.dat
echo cd %2»ftpcmd.dat
echo put %1» ftpcmd.dat
echo quit» ftpcmd.dat
ftp -n -s:ftpcmd.dat FTP.SERVER.COM
del ftpcmd.dat
save the file as superftp.bat. You will have to update details for each FTP server
then from dos,
superftp.bat myimage.jpg /sites/supersite.com/images/
this will copy myimage.jpg to the images folder on the server.
