1. FILE_SEARCH
1.1 Syntax
Result = FILE_SEARCH(Path_Specification)
Keywords: [, COUNT=variable ] [, /EXPAND_ENVIRONMENT ] [, /EXPAND_TILDE ] [, /FOLD_CASE ]
[, /FULLY_QUALIFY_PATH ] [, /ISSUE_ACCESS_ERROR ] [, /MARK_DIRECTORY ]
[, /MATCH_ALL_INITIAL_DOT | /MATCH_INITIAL_DOT ] [, /NOSORT ] [, /QUOTE ]
[, /TEST_DIRECTORY ] [, /TEST_EXECUTABLE ] [, /TEST_READ ] [, /TEST_REGULAR ]
[, /TEST_WRITE ] [, /TEST_ZERO_LENGTH ] [, /WINDOWS_SHORT_NAMES ]
The FILE_SEARCH function returns a string array containing the names of all files matching the input path specification. Input path specifications(规格) may contain wildcard(通配符) characters, enabling them to match multiple files.
找到该文件夹下后缀名为tif的所有文件
1.2 Example
PRO FILE_SEARCH_Function
path='G:\3_Test\4_IDL\Input\for layerstacking\Practice'
files=FILE_SEARCH(path,'*.tif',count=Filenum);count是这个函数的参数
print,Filenum
END
2. FILE_TEST
2.1 Syntex
Result = FILE_SEARCH(Path_Specification)
or for recursive searching,
Result = FILE_SEARCH(Dir_Specification, Recur_Pattern)
The FILE_TEST function checks files for existence and other attributes without having to first open the file.
2.2 Example
PRO FILE_TEST_Function
; Example from IDL help
; result = FILE_TEST(!DIR + '/bin/bin.darwin.i386', /DIRECTORY)
; PRINT, 'Intel-Mac Installed: ', result ? 'yes' : 'no'
file=FILE_TEST("G:\3_Test\4_IDL\Input\for layerstacking\Practice\1.tif")
print,file
END
结果是1,表示该文件是存在的。(先简单的用该函数来判断文件是否存在)