ftp automation


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?
I copy script from Documentation, but probably is not good.
I try delete files from local dir. When the files are not in the dir, so system print:
EXEC("del *.txt")
Could Not Find D:\test\source\*.txt
deleting files was successful
In fact, no file was found and nothing was deleted. And system should print out this message: "No *.txt files found."

This is "my" code:
Code: Select allLOCALCHDIR("D:\test\source\") $result=EXEC("del *.txt") IF($result!=0) IF($result==1) print("No *.txt files found.") ELSE print("Del failed.") END IF ELSE print("deleting files was successful") END IF
$result==1 ---> is this correct for "no files found"?
Thank you for your answers...
Hello Mihcal,

Command line programs (such as "del") usually returns 0 if the operation is done seccessfully and a non-zero value if not.

I suggest you to open a command prompt window (I mean the windows command line, nothing related to ScriptFTP) and play a bit with the command you want to launch from ScriptFTP. You can get the value returned by the last run command using the %ERRORLEVEL% environment variable. For example:
C:\> D:
D:\> cd \test\source\ (enter)
D:\> del *.txt (enter)
Error message from del command
D:\> echo %ERRORLEVEL% (enter)
Thanks, I tried use other functions and it already runs as follows:
Code: Select allLOCALCHDIR("D:\test\source\") GETLIST($list,LOCAL_FILES,"*.txt") $count=COUNTELEMENTS($list) IF($count==0) PRINT("No text files found.") GOTO :end END IF $result=EXEC("del *.txt") IF($result!=0) print("Del failed.") ELSE  print("Deleting files was successful.") END IF :end EXIT
Thanks for posting the script Mihcal. It will be useful for other users with the same question.