> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# fileListDir

> 列出目錄內容，並可選擇按檔名掩碼過濾結果。

列出指定路徑中的檔案和目錄。

## 必需的參數

* **path**: 將列出其目錄和檔案的完全限定路徑（例如，`/tmp/mydirectory`）。

## 可選的參數

* **mask**：用於過濾結果項目的模式。 預設為`*`。 例如，掩碼`*.json`匹配所有具有`.json`副檔名的檔案。
* **recurse**：是否遞迴列出項目。 允許的值為`false`和`true`。 預設為 `false`。
* **fileordir**：是否僅列出檔案或目錄。 允許的值為`all`、`files`和`dirs`。 預設為`all`。

## 輸出屬性

* **file:fullname**: 當前項目中檔案或目錄的完整路徑。
* **file:name**: 當前項目中檔案或目錄的名稱。
* **file:mtime**: 當前項目中檔案或目錄的寫入時間。
* **file:ctime**: 當前項目中檔案或目錄的建立時間。
* **file:atime**: 最近一次讀取或寫入當前項目中的檔案或目錄的時間。
* **file:attributes**: 當前項目中檔案或目錄的屬性清單。
* **file:extension**: 項目的副檔名。
* **file:size**: 檔案大小，以位元組為單位。
* **file:isdir**: 項目是檔案還是目錄。

## 範例

```xml theme={null}
<!-- Setting the path to monitor on the input item -->
<arc:set attr="input.path" value="/tmp/timesensitive" />
<!-- Enabling recursion to check all subdirectories within the input path -->
<arc:set attr="input.recurse" value="true" />
<!-- Checking for files only, across all directories found by the operation -->
<arc:set attr="input.fileordir" value="files" />
<!-- Calling the operation and passing in the input item and setting an output item -->
<arc:call op="fileListDir" in="input" out="result" >
  <!-- Executing an expression that checks each file creation date in each directory -->
  <arc:if exp="[result.file:ctime | dateadd('day', 1) | datediff | lessthan(0)]" >
    <!-- If it is older than 1 day, log an entry in the application log -->
    <!-- This can be expanded to add more logic such as sending an email using appSendEmail -->
    <arc:set attr="_log.info" value="The file [result.file:name] located at [result.file:fullname] has been idle within [input.path] for longer than 1 day." />
  </arc:if>
</arc:call>
```
