HISE Logo Forum
    • Categories
    • Register
    • Login

    How to rename Userpreset

    Scheduled Pinned Locked Moved Scripting
    5 Posts 3 Posters 298 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Lumi283
      last edited by

      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émi

      inline function renameFile (component, value) {
            if (value) {
               local presetName = "Victoria Violin";
               local file = "./" + presetName + ".preset";
               file.rename("renamed");
            }
      }
      
      CasmatC 1 Reply Last reply Reply Quote 0
      • CasmatC
        Casmat @Lumi283
        last edited by Casmat

        @Lumi283 you have to store the preset in a file object:

        Try this:

        //Userpresets location
        FileSystem.getFolder(FileSystem.UserPresets).getChildFile(presetname + ".preset")
        

        i make music

        L alhugA 2 Replies Last reply Reply Quote 0
        • L
          Lumi283 @Casmat
          last edited by

          @Casmat said in How to rename Userpreset:

          FileSystem.getFolder(FileSystem.UserPresets).getChildFile(presetname + ".preset")

          it's working thank you!

          1 Reply Last reply Reply Quote 1
          • alhugA
            alhug @Casmat
            last edited by

            @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);
            

            "HISE is for software developers. If you're not one you must become one." - David Healy

            CasmatC 1 Reply Last reply Reply Quote 0
            • CasmatC
              Casmat @alhug
              last edited by

              @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.

              i make music

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              48

              Online

              1.7k

              Users

              11.7k

              Topics

              101.8k

              Posts