Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENU MENU
Post here if you experience file transfer problems or unexpected errors.
I'm using ScriptFTP to download syslog files from a remote router. I use ScriptFTP to create today's date in YYYYMMDD format, then download/delete the files from the router.

Sometimes, if a site is quiet, no files are available to download on that day, OR there may be a single file on the router, but it's still being written to and is locked. So it can't be downloaded, so on that day the locally created folder is empty.

This isn't really a problem, until the end of the year, where I archive the year's downloaded file, and empty folders cause issues with the zipping software.

What I've tried is to put in a loop, that counts the files as so -

GETLIST($list,LOCAL_FILES,"*.*")

# Calculate the number of elements in the list
$number_of_elements=COUNTELEMENTS($list)

IF($number_of_elements==0)
PRINT("DELETING LOCAL FOLDER TO PREVENT ZIPPING ERRORS AT END OF YEAR: (".$TodayDate.")")
LOCALRMDIR("D:\".$TodayDate."")



However, I get the following error -

LOCALRMDIR("D:\20150104")
Deleting local dir D:\20150104
***** LOCALRMDIR Error #32 : Cannot remove local directory D:\20150104
***** The system said: The process cannot access the file because it is being used by another process.


Any suggestions? Have also tried RMDIR through EXEC but it gives the same error.