How to rename Userpreset
-
Hello, is it possible to use File.rename() to rename user presets? If yes, what should be the format of the relative path to locate and rename a .preset file? I tried the following code but it didn't work.
Thank you. Rémiinline function renameFile (component, value) { if (value) { local presetName = "Victoria Violin"; local file = "./" + presetName + ".preset"; file.rename("renamed"); } }
-
@Lumi283 you have to store the preset in a file object:
Try this:
//Userpresets location FileSystem.getFolder(FileSystem.UserPresets).getChildFile(presetname + ".preset")
-
@Casmat said in How to rename Userpreset:
FileSystem.getFolder(FileSystem.UserPresets).getChildFile(presetname + ".preset")
it's working thank you!
-
@Casmat Just the info I needed to get it to work. Thanks. The preset browser list updates quite slowly. A lot slower than if I'm using the built-in rename button. Is there a way to get it to update faster?
Here's the code I'm using:
Content.makeFrontInterface(600, 600); const uph = Engine.createUserPresetHandler(); reg presetName; uph.setPostCallback(function(presetFile) { presetName = Engine.getCurrentUserPresetName(); }); inline function onbtnRenameConfirmControl(component, value) { if (value) { local file = FileSystem.getFolder(FileSystem.UserPresets).getChildFile(presetName + ".preset"); file.rename("Rename"); } }; Content.getComponent("btnRenameConfirm").setControlCallback(onbtnRenameConfirmControl);
-
@alhug I'm personally using a custom preset browser and don't know if theres a refresh function for the browser, for my custom case, I have made a function which does the "refreshing" and I call it whenever there's a change thats made.