1)遍歷文件夾:
list_files( : : Directory, Options : Files)
Directory:目錄(文件夾路徑)
Options:選項
'files' | 指定搜索的格式為文件 |
'directories' | 指定搜索的格式為文件夾 |
'recursive' | 指定可以遍歷子文件夾下的文件 |
'follow_links' | |
'max_depth 5' | 指定遍歷的深度 |
'max_files 1000' | 指定遍歷的最大文件數目 |
Files:文件(文件的路徑)
2)文件格式篩選
tuple_regexp_select( : : Data, Expression : Selection)
Data:被選擇的文件路徑數組
Expression:文件格式的篩選規則
//. | 轉義 . |
(bmp|JPG) | 篩選的文件格式 |
'ignore_case' | 忽略大小寫 |
Selection:選擇出的文件路徑數組
示例:
1: * 遍歷文件夾D:/資料庫/Downloads
2: list_files ('D:/資料庫/Downloads', ['files','follow_links'], ImageFiles)
3:
4: * 篩選bmp或jpg格式的文件
5: tuple_regexp_select (ImageFiles, ['\\.(bmp|jpg)$','ignore_case'], ImageFiles)
6:
7: * 依次讀取圖片
8: for Index := 0 to |ImageFiles| - 1 by 1
9: read_image (Image, ImageFiles[Index])
10:
11: endfor