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

# File Formatters

> Formatters for working with file paths, names, extensions, and filesystem metadata in ArcScript.

## Common File Formatters

The following formatters are the most common file formatters. An example for each formatter is provided for reference.

<Note>The square brackets around the optional parameters of some formatters are not required. They are there to denote that the parameter is optional.</Note>

### fileext()

Returns the file extension from the specified file.

#### Example

```xml theme={null}
<arc:set attr="myFile" value="[FilePath]" />
<arc:if exp="[myFile | fileext() | equals('.err')]">
  <arc:throw code="1" desc="Error file detected." />
</arc:if>
```

### fullpath()

Returns the absolute path for the specified file or folder.

#### Example

```xml theme={null}
<arc:set attr="myFile.relativepath" value="../test.xml" />
<arc:set attr="myFile.absolutepath" value="[myFile.relativepath | fullpath()]" />
```

## More File Formatters

Below is the list of less-common formatters not included in the previous section.

### directory()

Returns the name of the directory specified by the folder path.

### direxists(\[ifexist]\[, ifnotexist])

This formatter returns *true* (or the value passed in as *ifexist*) if the folder at the specified path exists, and *false* (or the value passed in as *ifnotexist*) otherwise.

* **ifexist**: The optional value returned if the directory exists.
* **ifnotexist**: The optional value returned if the directory does not exist.

### filectime()

Returns the creation time of the specified file.

### fileexists(\[ifexist]\[, ifnotexist])

This formatter returns *true* (or the value passed in as *ifexist*) if the file at the specified path exists, and *false* (or the value passed in as *ifnotexist*) otherwise.

* **ifexist**: The optional value returned if the file exists.
* **ifnotexist**: The optional value returned if the file does not exist.

### filemtime()

Returns the last modification time of the specified file.

### filename()

Returns the file name from the specified file.

### filesize()

Returns the file size from the specified file.

### getcwd()

Returns the current working directory. The attribute that is passed into this formatter is ignored, so common practice is to use the default item `_` as the input. For example, `[_ | getcwd()]`.

### ischild(path\[, ifchild]\[, ifnotchild])

Returns *true* (or *ifchild*) if the *path* parameter is a child of the path represented passed in by the attribute value, and *false* (or *ifnotchild*) otherwise.

* **path**: The path to compare with the path represented by the attribute value.
* **ifchild**: The optional value returned if the parameter value is a child of the path represented by the attribute value.
* **ifnotchild**: The optional value returned if the parameter value is not a child of the path represented by the attribute value.

### pathcombine(path)

Combines two path strings.

* **path**: The path to be combined with the path represented by the attribute value.

### rootpath()

Returns the root directory for the specified path.

### tofilename()

Converts the attribute value to a valid file name. Replaces invalid characters with an underscore (`_`).
