Hi,
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:
This is "my" code:
Thank you for your answers...
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")In fact, no file was found and nothing was deleted. And system should print out this message: "No *.txt files found."
Could Not Find D:\test\source\*.txt
deleting files was successful
This is "my" code:
Code: Select all
$result==1 ---> is this correct for "no files found"?LOCALCHDIR("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
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:
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)
1
liked Script FTP? Try our other product Email Parser
Thanks, I tried use other functions and it already runs as follows:
Code: Select all
LOCALCHDIR("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.
liked Script FTP? Try our other product Email Parser