Zack Lovatt

I focus on toolkitting, building custom studio pipelines, expression rigging projects, and creating data-driven animation workflows.

Mail GitHub LinkedIn Skype Vimeo
July 22, 2015

ExtendScript: Delete Saved Settings

Posted In: scripting

Working in ExtendScript and need to delete a setting you’ve saved to your users’ preferences file? Did some looking around and it seems there was no way. Until now!

Found that you can use the preferences.deletePref() method to delete settings. Just need to target it with the prefix “Settings_”, and save the prefs file afterward, but otherwise seems to work just fine.

The only caveat here is that the section header will remain, however that seems to have no negative effect.

var sectionTag = "testSectionTag";
var keyTag = "testKeyTag";
var keyValue = "I'm only temporary!";

// Sample save + call
app.settings.saveSetting(sectionTag, keyTag, keyValue);

if (app.settings.haveSetting(sectionTag, keyTag) == true)
    alert(app.settings.getSetting(sectionTag, keyTag));

// The magic delete
app.preferences.deletePref("Settings_" + sectionTag, keyTag);

Would you like to share your thoughts?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.