Highlighted

Tweak a simple script to select folder using default file explorer

Participant ,
Mar 24, 2020

Copy link to clipboard

Copied

Hi guys,

the following script has a huge problem for me: it opens up a file browsing dialog which is not the one I want and makes my life difficult everytime. 

Is there any way to tweak the code so it opens up the usual Windows File Explorer?

 

{
  // Change Render Locations.jsx
  //
  // This script prompts the user for a new output folder to use for queued items in the Render Queue.

  function ChangeRenderLocations() {
    var scriptName = "Change Render Locations";
    var newLocation = Folder.selectDialog("Select a render output folder...");

    if (newLocation != null) {
      app.beginUndoGroup(scriptName);

      // Process all render queue items whose status is set to Queued.
      for (i = 1; i <= app.project.renderQueue.numItems; ++i) {
        var curItem = app.project.renderQueue.item(i);

        if (curItem.status == RQItemStatus.QUEUED) {
          // Change all output modules for the current render queue item.
          for (j = 1; j <= curItem.numOutputModules; ++j) {
            var curOM = curItem.outputModule(j);

            var oldLocation = curOM.file;
            curOM.file = new File(newLocation.toString() + "/" + oldLocation.name);

            alert("New output path:\n" + curOM.file.fsName, scriptName);
          }
        }
      }
      app.endUndoGroup();
    }
  }
  ChangeRenderLocations();
}

Annotazione 2020-03-24 085121.png

Topics

Scripting

Views

56

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Tweak a simple script to select folder using default file explorer

Participant ,
Mar 24, 2020

Copy link to clipboard

Copied

Hi guys,

the following script has a huge problem for me: it opens up a file browsing dialog which is not the one I want and makes my life difficult everytime. 

Is there any way to tweak the code so it opens up the usual Windows File Explorer?

 

{
  // Change Render Locations.jsx
  //
  // This script prompts the user for a new output folder to use for queued items in the Render Queue.

  function ChangeRenderLocations() {
    var scriptName = "Change Render Locations";
    var newLocation = Folder.selectDialog("Select a render output folder...");

    if (newLocation != null) {
      app.beginUndoGroup(scriptName);

      // Process all render queue items whose status is set to Queued.
      for (i = 1; i <= app.project.renderQueue.numItems; ++i) {
        var curItem = app.project.renderQueue.item(i);

        if (curItem.status == RQItemStatus.QUEUED) {
          // Change all output modules for the current render queue item.
          for (j = 1; j <= curItem.numOutputModules; ++j) {
            var curOM = curItem.outputModule(j);

            var oldLocation = curOM.file;
            curOM.file = new File(newLocation.toString() + "/" + oldLocation.name);

            alert("New output path:\n" + curOM.file.fsName, scriptName);
          }
        }
      }
      app.endUndoGroup();
    }
  }
  ChangeRenderLocations();
}

Annotazione 2020-03-24 085121.png

Topics

Scripting

Views

57

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mylenium LATEST
Most Valuable Participant ,
Mar 24, 2020

Copy link to clipboard

Copied

You probably could refactor it using a custom file.save() dialog or something, but then you'd have to write your own functions to extract the actual folder name from it.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...