🆕renameFile
To rename a file in a field or record.
This function renames a file by specifying either:
A
file
object that contains the necessary information (nid
and the file name).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.
Caution: When using this function on native apps (iOS, iPadOS macOS, Android), it must be enclosed in a do as server
code block within the formula editor.
Syntax
renameFile(file, string)
renameFile(nid, string, string)
Return
file
Examples
Use
renameFile(file, newFileName)
to rename an image attached to a record and displayed in an Image field:
Result: The image in the Image field is renamed to "A1234_Front_0729.jpg".
Use
renameFile(nid, oldFileName, newFileName)
to rename a PDF attached to a record:
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