GETFILEARRAY Get list of matching local file(s) |
Top Previous Next |
If you need to download a file please see the Help page for the RCVFILE script command. Note Robo-FTP offers numerous commands for monitoring for files and iterating over directory structures on local and remote servers. There is significant overlap in capabilities between these commands, but there are also important differences that often make one command better suited to a particular task than the others. Please see the chapter Monitoring for Files and Iterating over Directory Structures for a description of these commands and recommendations for which commands to use in a particular situation.
This script command searches the current local directory for the file specified in the [ file name ] argument. If any matching files are found, the full path to that file is added to the array arrayname[*].
The /skip_changing and /skip_changing_seconds options are useful when there is a chance that a file being processed by Robo-FTP is also being modified by some other process.
GETFILEARRAY ignores flies that are exclusively locked by other applications or that are inaccessible due to security permissions. This command also ignores all files with the "hidden" or "system" file system attribute. You can use the DOS attrib.exe program to change these attributes. GETFILEARRAY will not ignore a hidden file if you specify that file's name explicitly.
;; In this example, myfile.txt has the "hidden" file system attribute set GETFILEARRAY "*.txt" ;; This will ignore "myfile.txt" GETFILEARRAY "myfile.txt" ;; This will find myfile.txt
This command returns $ERROR_NO_FILE_FOUND when no file matches the [ file name ] argument. The /timeout option can be used to wait for the existence of an expected file. This is accomplished by periodically polling the folder during the waiting period. If the file does not appear before the timeout expires $ERROR_WAIT_TIMED_OUT is returned.
Use the WORKINGDIR command to change the current directory before calling GETFILE if the file you want to find in not in the current directory or, alternatively, the /subdirs option may be used to find files in any subdirectory of the current directory.
This command is especially with directories containing very large numbers of files. Each call to GETNEXTFILE or GETFILE with wildcards must iterate over previously checked file on each call. So for very large directories or directory trees it is much faster to do something like...
GETFILEARRAY "*" var SET counter = 0 SET size = var[*] IFNUM= size 0 GOTO loop_done ;; skip loop if array is empty :top_of_loop GETNEXTFILE var[counter] IFERROR GOTO next IFSTRCMP %nextfile "" GOTO dir !DISPLAY %nextfile !DISPLAY %nextfolder !DISPLAY %nextpath PAUSE /for=1 GOTO next :dir IFSTRCMP %nextfolder "" GOTO error !DISPLAY %nextfile !DISPLAY %nextfolder !DISPLAY %nextpath PAUSE /for=1 :next SET counter = counter + 1 IFNUM< counter size GOTO top_of_loop :loop_done
Important This command returns $ERROR_NO_FILE_FOUND when no file matches the [ file name ] argument. This is not the same error as $ERROR_NO_FILES_FOUND. Please be sure to test for the correct error code.
Related command(s): GETREWIND, GETNEXTFILE, FTPGETFILE, FTPGETREWIND, GETSITEFILE, FILECOMPARETO, FILECOMPAREFROM See also: Using the %nextfile, %nextpath, and %nextfolder Variables, Using the %nextfiledate, %nextfiledatetime, %nextfilesize, and %nextfiletime Variables, Using Wildcards, Using Arrays |