KB Article #47932
How to retrieve files from the FTP server when there are files ending with ".ok". We want to retrieve particular files using the FTP scirpt
Suppose we have following files in the FTP server-
example.ok
example
example_1.ok
example_1
example_2.ok
example_2
example_3
example_4
In this we want to retrieve only those files from FTP server which do not have the extension ".ok" but must have a corresponding file which have the extension ".ok".
For example, for the above files only example, example_1 and example_2 should be retrieved by FTP retrieve method because they have their corresponding files example.ok, example_1.ok and example_2.ok file [means files with the same name and have the extension ".ok"]. So in this manner the files example_3 and example_4 will not be retrieved by FTP retrieve method because the directory does not contain the files example_3.ok and example_4.ok.
Resolution
The above query or the queries like the above, we can try with the combination of LIST command. Please try the below script in FTP retrieve method to get the desired result-
-LIST "*" INTO %F {
-LIST "*.ok" INTO %G{
%H=%F".ok";
IF(%G=%H){
-RECV %F;
IF(%FTPSTATUS IN "200"-"299") {
DELETE %F;
}
}
}
}
The above script practically checks for each file in the folder whether it has a correspondent with .ok extension or not. It will take some longer time to execute.