Windows has included batch files since before it existed… batch files are really old! Old or not, I still find myself frequently creating batch files to help me automate common tasks. One common task is uploading files to a remote FTP server. Here’s the way that I got around it.
First, you will have to create a file called fileup.bat in your windows directory, or at least inside some directory included in your path. You can use the “path” command to see what the current path is.
Inside the batch file, you will want to paste the following:
echo user MyUserName> ftpcmd.dat
echo MyPassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat SERVERNAME.COM
You will want to replace the MyUserName, MyPassword and SERVERNAME.COM with the correct values for your ftp server. What this batch file is doing is scripting the ftp utility using the -s option for the command line utility.
The batch file uses the “echo” command to send text to the ftp server as if you had typed it. In the middle of the file you can add extra commands, potentionally a change directory command:
echo cd /pathname/>>ftpcmd.dat
In order to call this batch file, you will call the batchfile using the fileup.bat name that we gave it, and pass in the name of a file as the parameter. You don’t have to type the .bat part of the filename to make it work, either.
> fileup FileToUpload.zip
Connected to ftp.myserver.com.
220 Microsoft FTP Service
ftp> user myusername
331 Password required for myusername.
230 User myusername logged in.
200 Type set to I.
ftp> put FileToUpload.zip
200 PORT command successful.
150 Opening BINARY mode data connection for FileToUpload.zip
226 Transfer complete.
ftp: 106 bytes sent in 0.01Seconds 7.07Kbytes/sec.
And that’s all there is to it. Now your file should be sitting on the remote server.
- › 20 of the Best Tips and Tricks for Getting the Most out of the Windows Command Line
- › How to Connect to FTP Servers in Windows (Without Extra Software)
- › How to Add a Shortcut to Pretty Much Anything on Android
- › The Best DDR5 RAM of 2023
- › 5 Reasons to Upgrade to the 11th Gen Kindle Paperwhite
- › Goodbye, Cortana
- › Physical vs. Digital Games: Should You Buy Physical Games?
- › How to Optimize Multiple Stops Into a Round Trip on Google Maps