Efficient way to rename files in ThingWorx FileRepository (maintain numeric order after add/delete)
Hi everyone,
I’m working with a ThingWorx FileRepository where each subfolder contains only 3–4 images (like step images in an Experience).
Whenever I add or delete images, I want to re-sort and rename all files sequentially — e.g.,
so the order always stays clean and consistent.
Question:
Given that each folder has only a few files (3–4 images), should I:
-
Keep this simple in-ThingWorx loop (since performance impact is negligible), or
-
Use a REST API batch rename approach for better scalability?
Option 1 – In-ThingWorx loop (current working code)
✅ Simple and clear
⚠️ Calls RenameFile() multiple times (one per file)
Option 2 – REST API Batch Rename from Thingworx
✅ Ideal if many files or automation outside ThingWorx
⚠️ Adds external dependency
const files = [
{ path: "/Folder/old1.png", newName: "1.png" },
{ path: "/Folder/old2.png", newName: "2.png" }
];
for (const [i, f] of files.entries()) {
const body = {
path: f.path,
name: `/Folder/${f.newName}`
};
await fetch("https://<ThingworxServer>/Thingworx/Things/MyFileRepository/Services/RenameFile", {
method: "POST",
headers: {
"Content-Type": "application/json",
"appKey": "<YourAppKey>"
},
body: JSON.stringify(body)
});
}
My current thought:
Since each folder has at most 3–4 images, I assume the current in-ThingWorx loop approach is fine and has no performance issue.
However, I’d appreciate confirmation or best-practice advice —
Is there a recommended pattern in ThingWorx for renaming small batches of files efficiently?

