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...
What can I do to fix this...
Also is there a way of changing the date format to DDMMYYYY.
Thanks
Mark....
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")The GETLIST commend is putting a leading character and it therefore does not match the "$currentdate".
Getting directory listing of current remote directory
Found 1 directory.
|20111108
20111108
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]
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]
liked Script FTP? Try our other product Email Parser
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....
Cheers
Mark....