FTP tools for UKCloudSync

Modified on Fri, 29 May, 2015 at 1:02 AM

All of the CloudSync "share" products can be accessed via FTP at the following FTP server: ftpdrive.ukcloudsync.net


The following example script automates removing any files older than 30 days within a folder called "CCTV":


 

@echo off
@REM # Change these variables to use your FTP details:
setlocal
SET FTPfileAgeDays=30
SET FTPlocalFolder=C:\Temp
SET FTPscript=C:\Temp\FTPscript.scr
SET FTPfilelist=C:\Temp\FTPfiles2delete.txt
SET FTPscriptDELETE=C:\Temp\FTPscriptDELETE.scr
SET FTPserver=ftpdrive.ukcloudsync.net
SET FTPuser=YOUR_USERNAME
SET FTPpass=YOUR_PASSWORD
SET FTPdir=CCTV

@REM # Get date today
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (
set today=%%c%%b%%a
@REM 	# %%c%%b%%a = date in format YYYYMMDD
set todayYYYY=%%c
)
 
@REM # Try to delete the local FTPscript files if already exists
IF EXIST %FTPscript% del /F %FTPscript%
IF EXIST %FTPfilelist% del /F %FTPfilelist%
IF EXIST %FTPscriptDELETE% del /F %FTPscriptDELETE%

@REM # Build a Windows FTP.exe script file
@REM    # FTP connect and login, change to remote directory
echo open %FTPserver%>%FTPscript%
echo %FTPuser%>>%FTPscript%
echo %FTPpass%>>%FTPscript%
echo cd %FTPdir%>>%FTPscript%
echo lcd %FTPlocalFolder%>>%FTPscript%
@REM    # capture list of files
echo dir . %FTPfilelist%>>%FTPscript%
echo quit>>%FTPscript%
@REM    # Run the FTP script
ftp -s:%FTPscript%

@REM # Build a Windows FTP.exe script file to DELETE files
@REM    # FTP connect and login, change to remote directory
echo open %FTPserver%>%FTPscriptDELETE%
echo %FTPuser%>>%FTPscriptDELETE%
echo %FTPpass%>>%FTPscriptDELETE%
echo cd %FTPdir%>>%FTPscriptDELETE%
@REM    # Loop through list of files
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=6,7,8,*" %%a in (%FTPfilelist%) do (
    echo FILE: %%d
@REM	# Extract file date
@REM	# Convert Linux/Unix month name to number
IF %%a==Jan SET m=01
IF %%a==Feb SET m=02
IF %%a==Mar SET m=03
IF %%a==Apr SET m=04
IF %%a==May SET m=05
IF %%a==Jun SET m=06
IF %%a==Jul SET m=07
IF %%a==Aug SET m=08
IF %%a==Sep SET m=09
IF %%a==Oct SET m=10
IF %%a==Nov SET m=11
IF %%a==Dec SET m=12

echo Month: %%a [!m!]   Day: %%b   Year[yyyy] or Time[hh:mm]: %%c

@REM	# Convert Linux/Unix date to number of days since today
SET yyyy=%%c
SET char=%%c
SET c=!char:~2,1!
if !c!==: SET yyyy=%todayYYYY%

SET yyyymmdd=!yyyy!!m!%%b
SET /a age=%today%-!yyyymmdd!
echo Age: !age! days [Today: %today% - !yyyymmdd!]
@echo:

@REM	# If old enough, add file to DELETE command list
IF !age! GEQ %FTPfileAgeDays% echo DEL %%d>>%FTPscriptDELETE%
)
echo quit>>%FTPscriptDELETE%

@REM    # Run the FTP script
echo #########################################################################
echo # Logging into FTP server and deleting any files older than %FTPfileAgeDays% days old #
echo #########################################################################
echo on
ftp -s:%FTPscriptDELETE%
@echo #################################################
@echo # Files more that %FTPfileAgeDays% days old have been deleted #
@echo #################################################

 

Windows *.BAT file attached (zipped)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article