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.
Need help writing a script? Have any question about ScriptFTP?
We are developing a script to upload files to a remote FTP server but encountered a problem and would like to seek for your advice.

We regularly upload the files generated from our system, and after upload we move the uploaded files to a history folder for backup purpose (by EXEC a move command)

However we found that the history folder sometimes may not exist.. So I would like to create the history folder when the folder is not exist.

I checked LOCALMKDIR can help to create folder, but do I have any chance to check if the folder exist before calling this command?

Thank you for you help in advance!
In these cases most users place a LOCALMKDIR call that will always try to create the folder. In the case the folder aready exists it will show an error but the script will continue normally (the error is ignored)

If you want a more clean solution that checks for the folder existence before calling LOCALMKDIR, as you suggested, try this script

[scriptftp="create_folder.ftp"]# The following script creates
# the directory D:\mydir\myexampledir
# only if it does not previously exist


# Set the current local directory to D:\mydir
LOCALCHDIR("D:\mydir")

# Get the list of the subdirectories under D:\mydir
GETLIST($list,LOCAL_DIRECTORIES)

# For each directory name check if the name
# matches myexampledir
$found="FALSE"
FOREACH $directory_name IN $list
IF($directory_name=="myexampledir")
$found="TRUE"
END IF
END FOREACH

# If D:\mydir\myexampledir does not exist
# create it
IF($found == "FALSE")
LOCALMKDIR("myexampledir")
END IF[/ScriptFTP]