- GETTING STARTED
- GUIDES
- COMMANDS
- Server connection
- File Transfer
- Directory operations
- File operations
- Script output
- Miscellaneous
- OTHER
Handling local files
ScriptFTP does not provide any commands for copying, deleting or moving local files because these commands are already included in the operating system. The way to access them is using the EXEC command. For example:
OPENHOST("ftp.host.com","myuser","mypassword")
# Delete all temporary files from
# LocalWebFolder before synchronizing
EXEC("del /F /Q C:\LocalWebFolder\*.tmp")
SYNC("C:\LocalWebFolder","/www",UPLOAD)
CLOSEHOST
In the above script, we use the EXEC command to call the external program "del". The result is the same as if you had opened a command line window and typed "del /Q C:\LocalWebFolder". For further information about using the Windows command line programs type "help" at the command line.
Note that some external commands such as copy, rename and del need the file name enclosed in double quotes when it contains spaces. For example, if we need to copy a file named Report 2008.xls to a directory whose path is C:\Reports:

The first attempt returned an error because copy were trying to find the files Report and 2008.xls and they do not exist. In the second attempt we enclosed the file name between quotes and it worked. Copy understood because of the quotes that both text strings were part of the same file name.
In this case, to execute the external command copy within ScriptFTP we also have to use double quotes to enclose the file name but the problem is that it seems that ScriptFTP also uses double quotes to separate command parameters. So, how can this command be written in a script without making a syntax error? Just use single quotes, ScriptFTP accepts both:
# Correct
EXEC('copy "Report 2008.xls" C:\Reports')
# Wrong. Copy will show an error because
# it tries to copy the files "Report" and "2008.xls"
# which do not exist.
EXEC("copy Report 2008.xls C:\Reports")
# Wrong. ScriptFTP will show a syntax error
# because of the EXEC command syntax, the quotes use
# is incorrect.
EXEC("copy "Report 2008.xls" C:\Reports")

