The first line is the ftp directory, the second line is local directory. The first line is site, the second is username, and the third is FTP password. REM Enter your ftp site information here. Set "bmk= %~1 " set "emk= %~2 " set "src= %~3 " set "bExtr=" set "bSubs=" if " %src% " = "" set src = %~f0 & rem if no source file then assume THIS file for /f "tokens=1,* delims=]" %%A in ( 'find /n /v "" " %src% "' ) do ( if /i " %% B" = " %emk% " set "bExtr=" & set "bSubs=" if defined bExtr if defined bSubs ( call echo. ftp" GOTO : EOF : extractFileSection StartMark EndMark FileName - extract a section of file that is defined by a start and end mark : : - StartMark - start mark, use '.:S' mark to allow variable substitution : : - EndMark - optional end mark, default is first empty line : : - FileName - optional source file, default is THIS file : $created 20080219 :$changed 20100205 :$categories ReadFile : $source SETLOCAL Disabledelayedexpansion
Ftp server solution download#
REM - Execute Ftp Script, download filesįtp -i -s: " %temp% \ %~n0. ftp" rem Notepad "%temp%\%~n0.ftp" For %%A In ( %FtpCommand% ) Do Echo. ftp"|Findstr %FindStrArgs% "' ) Do ( Call Set "FileList= %% FileList %% " %%A "" ) REM - Extract Ftp Script to upload files that don't exist in remote folder Set "FtpCommand=mput" For %%A In ( %FileList% ) Do set "Exist=Y" For /F "Delims=" %%A In ( '"dir /b " %localdir% "|Findstr %FindStrArgs% "' ) Do ( If Not defined Exist Call Set "FtpCommand= %% FtpCommand %% " %%~A "" ) Call : extractFileSection "" "-" > " %temp% \ %~n0. ftp" Rem Notepad "%temp%\%~n0.ftp" REM - Execute Ftp Script, collect File Names Set "FileList=" For /F "Delims=" %%A In ( '"Ftp -v -i -s:" %temp% \ %~n0. txt Set FindStrArgs =/E /C: ".mp3" REM - Extract Ftp Script to create List of Files Set "FtpCommand=ls" Call : extractFileSection "" "-" > " %temp% \ %~n0. PAUSE EXIT ) REM - : RUNSCRIPT REM Run script to download the new files CD /d %~dp0 ECHO Running FTP Script GOTO : RUNSCRIPT ) else ( ECHO LOCAL DIRECTORY IS Empty
IF %size% gtr 0 ( REM Creating FTP script ECHO Creating FTP Script to download remote filesįOR /F "tokens=*" %%G IN (local.txt ) DO ECHO put " %% G" >ftpscript.txt REM Sets current directory CD /d %~dp0 REM - FOR /f %%i IN ( "local.txt" ) DO SET size = %%~zi REM - REM Checking Local Directory ECHO Checking Local DirectoryĭIR /b /s *.pgp %LOCALFILEDIR% >local.txt REM Your FTP directory that you would like to download from (Example: public_html/downloads) SET FTPDIR =FTP DIRECTORY HERE
REM Your FTP credentials SET FTPUSERNAME =USERNAME 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