🆕renameFile

To rename a file in a field or record

This function renames a file by specifying either:

  1. A file object which contains the necessary information (nid and the file name).

  2. nid and the file name as separate parameters.

The file object can either come from an Image field or be created using the file(this, "name") function. In both cases, the newName parameter is required.

Syntax

renameFile(file, string)

renameFile(nid, string, string)

Return

file

Examples

  1. Use renameFile(file, newFileName) to rename an image attached to a record and displayed in an Image field:

Image := renameFile(Image, "A1234_Front_0729.jpg")

Result: The image in the Image field is renamed to "A1234_Front_0729.jpg."

  1. Use renameFile(nid, oldFileName, newFileName) to rename a PDF attached to a record:

renameFile(this, "Offer_0724.pdf", "Offer_0724-1.pdf")

Result: The PDF in the record is renamed from "Offer_0724.pdf" to "Offer_0724_1.pdf."

See also

removeFile which securely removes a file from a field or record.

importFile which imports a file from a URL and saves it in a record.

shareFile which returns a URL of a specific file.

Last updated