Happy holidays!

I apologize that I haven’t posted anything new in a few days. I have been busy learning Powershell! In the mean time, here is another helpful FTP script.

The following script will automatically upload the files from your local directory to your FTP server.

@ECHO OFF
TITLE Automatic FTP Uploader
CLS
REM ----------------------------CUSTOM CONFIGURATIONS---------------------------------------
  
REM This is your local directory that you use to store your files (Example: "C:\Users\johndoe\Documents")
SET LOCALFILEDIR=LOCAL DIRECTORY HERE
  
REM Your FTP credentials
SET FTPUSERNAME=USERNAME
SET FTPPASSWORD=PASSWORD
SET FTPHOST=FTP.HOSTNAME.COM
  
REM Your FTP directory that you would like to download from (Example: public_html/downloads)
SET FTPDIR=FTP DIRECTORY HERE
 
REM ------------------------------------------------------------------------------------------
  
  
REM Checking Local Directory
ECHO Checking Local Directory
DIR /b /s /c %LOCALFILEDIR%>local.txt
  
REM Sets current directory
CD /d %~dp0
  
REM ------------------------------------------------------------------------------------------
FOR /f %%i IN ("local.txt") DO SET size=%%~zi
IF %size% gtr 0 (
  
REM Creating FTP script
ECHO Creating FTP Script to download remote files
ECHO %FTPUSERNAME%>ftpscript.txt
ECHO %FTPPASSWORD%>>ftpscript.txt
ECHO ascii>>ftpscript.txt
ECHO lcd %LOCALFILEDIR%>>ftpscript.txt
ECHO cd %FTPDIR%>>ftpscript.txt
FOR /F "tokens=*" %%G IN (local.txt) DO @ECHO put "%%G">>ftpscript.txt
ECHO bye>>ftpscript.txt
GOTO:RUNSCRIPT

) else (
ECHO LOCAL DIRECTORY IS Empty
PAUSE
EXIT
)
REM ------------------------------------------------------------------------------------------

  
:RUNSCRIPT
REM Run script to download the new files
CD /d %~dp0
ECHO Running FTP Script
FTP -s:ftpscript.txt %FTPHOST% > nul
GOTO:DONE
REM ------------------------------------------------------------------------------------------
 
  
:Done
ECHO Done.
PAUSE