ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Post here if you experience file transfer problems or unexpected errors.
Hi,

I am a first time user of ScritpFTP....this is great....everything I need to make me feel like a real programmer, but....!

Below is the script I have created to identify if a directory exists with todays date ie 20111108 if not create it....

[scriptftp="script.ftp"]#Check to see if directory with todays date exists if not create it
GETLIST($checkdir,REMOTE_DIRECTORIES,$currentdate)
PRINT($checkdir)
PRINT($currentdate)
# problem with returned directory list - leading character
IF($checkdir!="$currentdate")
# Create directory with current date
MKDIR($currentdate)
END IF[/ScriptFTP]

However the script returns...
GETLIST(REMOTE_DIRECTORIES,"20111108")
Getting directory listing of current remote directory
Found 1 directory.
|20111108
20111108
The GETLIST commend is putting a leading character and it therefore does not match the "$currentdate".

What can I do to fix this...

Also is there a way of changing the date format to DDMMYYYY.

Thanks

Mark....
Hello,

Welcome to the forum. You can try putting "|" before the date:

[scriptftp="sample.ftp"]IF($checkdir!="|".$currentdate)
# Create directory with current date
MKDIR($currentdate)
END IF[/ScriptFTP]

But a better (and cleaner) way to see if the directory actually exists or not is:

[scriptftp="script.ftp"]#Check to see if directory with todays date exists if not create it
$directory_to_find=GETTIME(FORMAT3)
$found="FALSE"
GETLIST($directory_list,REMOTE_DIRECTORIES)

FOREACH $directory IN $directory_list
IF($directory==$directory_to_find)
$found="TRUE"
END IF
END FOREACH[/ScriptFTP]
Thanks, I went with option A putting "|" in front. Because we are using the filetr option in the GETLIST and not using the rest of the directory listing it seams to be a much simpler fix.

Cheers

Mark....