Modify file names and file paths

You can modify file names and paths in a KCM Core script.

<full file name>[<path>,<extension>]

This operation assumes that <full file name> is a valid file name. The result of this operation is a valid file name. The name itself is the same as the name of <full file name>, but the path is replaced by <path> and the extension by <extension>. When an empty string "" is specified, the path or extension are left blank. When <path> or <extension> are not specified, the path or extension of <full file name> is not changed.

Only the names are modified, not the files themselves. In other words, by modifying a file name the file itself is not moved on the file system nor is it converted to a different file format.

See the following table for examples.

Expression

Result

Description

"c:\temp\test.doc"["",]

"\test.doc"

path removed

"c:\temp\test.doc"[,""]

"c:\temp\test."

extension removed

"c:\temp\test.doc"[,]

"c:\temp\test.doc"

nothing happened

"c:\temp\test.doc"["",""]

"\test."

path removed and extension removed

"c:\temp\test.doc"["c:\archive","pdf"]

"c:\archive\test.pdf"

path and extension changed