COMPASS: add prefix to files bulk

Hello, is there a ready-to-go solution to rename all files in a Compass repository (and sub-repository) ?

My goal is to add [DEPRECATED] in front of lot file’s names.

Maybe it is simple to developpe this in SLATE ?

Hi @gdf,

Thanks for the question. Short version: there’s no built-in bulk-rename and it isn’t something you can script against the Platform API today either.

The traversal half is fine. You can list the children of a folder or project and recurse into sub-folders to enumerate everything. The gap is the rename: updating the display name of the resources inside (datasets etc) isn’t currently exposed in the Platform API, so a script that prepends [DEPRECATED] to each item’s name isn’t achievable end to end right now.

This is a reasonable ask and something we should support. I’ll get resource rename onto our backlog. I can’t promise a timeline, but I’ll follow up here if there’s progress.

One check: by “repository” do you mean a Compass folder/project, or a Code Repository? Those are different systems with different answers and I want to make sure I’m pointing you at the right one.

Thank you for your fast and precise answer.

By repository I mean Compass folder.

In addition “files” are mostly datasets, contour, slate, workshop, notpad.

Best regards.

Correct, I checked official documentation for update dataset name, and we don’t have any API for such task yet, but indeed this can be something very important when required to move any POC project to PROD or any PROD project to DEPRECATED state.

I tried to check in developer tool as well and when we rename and resources, Foundry calls graphql gateway which is not accessible for now normally.

Is this a one-off, or something you want to enable from an app? If one-off / occasional, AI FDE should be able to help you to do this quickly if you point it to the directory and enable the edit_resource_metadata tool

@pedro Sorry, I’m not sure what is the tool you are pointing for. I guess this is an Admin Feature or a feature that I can’t access.

For information I achieved a soution by using SLATE + COMPASS-SERVICE API.

Here is an overview of my solution.

A- recursive read of folder resources

step1: reading of all resources in a given folder RID

step2: 2 functions + events:

  • 1st f() = filtering on folders then enrich variable → v_folders_recursive_list
  • 2nd f() = filtering on files then enrich variable → v_files_recursive_list

step3: restart from step 1 with folder RID replaced by 1st folder of v_folders_recursive_list

Each loop tag folders of v_folders_recursive_list with a status AWAITING >PROCESSING > DONE

B- Loop renaming of files

A button trigger a set of functions/variables/events that loops over v_files_recursive_list and rename files 1-by-1. Here also a status AWAITING >PROCESSING > DONE is allocated to each files and changed after each loop to correctly track files that wre edited and move to the next one.

If you don’t have AI FDE enabled in your stack and have that option, I greatly recommend it. It’s an insane productivity booster. Glad you got to a solution though