Batch Render Regions to Filenames??

Comments

3d87c4 wrote on 11/26/2023, 1:32 AM

@NickHope: Thanks, I suspect it's a combination of W11 vs. W10 and the smaller screen on my laptop. (I noticed @Former user mentioned using a larger monitor and W10 too in his thread about editing 8K video.)

I have been using it regularly for a while, but feared I'd introduced the problem with the hidden first character when I edited the menus & thought I should mention it while folks were working on it.

Last changed by 3d87c4 on 11/26/2023, 1:34 AM, changed a total of 1 times.

Del XPS 17 laptop

Processor    13th Gen Intel(R) Core(TM) i9-13900H   2.60 GHz
Installed RAM    32.0 GB (31.7 GB usable)
System type    64-bit operating system, x64-based processor
Pen and touch    Touch support with 10 touch points

Edition    Windows 11 Pro
Version    22H2
Installed on    ‎6/‎8/‎2023
OS build    22621.1848
Experience    Windows Feature Experience Pack 1000.22642.1000.0

NVIDIA GeForce RTX 4070 Laptop GPU
Driver Version: 31.0.15.2857
8GB memory
 

Former user wrote on 11/26/2023, 11:12 AM

@3d87c4 I'm using a 32" Dell monitor on Windows 10.

This is the script I used, the last one @jetdv posted in the comments above.

/* Batch Render v2 by SkrowTox */
/* Update 0                    */

using System;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using ScriptPortal.Vegas;
using System.Security.Principal;
using Region = ScriptPortal.Vegas.Region;

public class EntryPoint
{
    // set this to true if you want to allow files to be overwritten
    private bool _overwriteExistingFile = false;
    private String _defaultBasePath = "Untitled";
    private Vegas _myVegas = null;
    ArrayList _selectedTemplates = new ArrayList();
    private static int _regionStartIndex = 1;
    private bool _canceled = false;

    static string IsAnAdministrator()
    {
        WindowsIdentity identity =
            WindowsIdentity.GetCurrent();
        if (identity != null)
        {
            WindowsPrincipal principal = new WindowsPrincipal(identity);
            return principal.IsInRole(WindowsBuiltInRole.Administrator) ? "True" : "False";
        }
        return "Error";
    }

    enum RenderMode
    {
        Project = 0,
        Selection,
        Regions
    }

    class RenderItem
    {
        public readonly Renderer Renderer = null;
        public readonly RenderTemplate Template = null;
        public readonly String Extension = null; public RenderItem(Renderer r, RenderTemplate t, String e)
        {
            Renderer = r;
            Template = t;
            // need to strip off the extension's leading "*"
            if (null != e) Extension = e.TrimStart('*');
        }
    }

    static String FixFileName(String name)
    {
        const Char replacementChar = '-';
        foreach (char badChar in Path.GetInvalidFileNameChars())
        {
            name = name.Replace(badChar, replacementChar);
        }
        return name;
    }

    static void ValidateFilePath(String filePath)
    {
        if (filePath.Length > 260)
            throw new ApplicationException("File name too long: " + filePath);
        foreach (char badChar in Path.GetInvalidPathChars())
        {
            if (0 <= filePath.IndexOf(badChar))
            {
                throw new ApplicationException("Invalid file name: " + filePath);
            }
        }
    }

    bool ProjectHasVideo()
    {
        foreach (Track track in _myVegas.Project.Tracks)
        {
            if (track.IsVideo())
            {
                return true;
            }
        }
        return false;
    }

    bool ProjectHasAudio()
    {
        foreach (Track track in _myVegas.Project.Tracks)
        {
            if (track.IsAudio())
            {
                return true;
            }
        }
        return false;
    }

    static string GetValue(string attName)
    {
        return Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\SkrowTox\SonyVegasSettings", attName, "").ToString();
    }

    static void SetValue(string attName, string attValue)
    {
        Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\SkrowTox\SonyVegasSettings", attName, attValue);
    }

    public void FromVegas(Vegas vegas)
    {
        _myVegas = vegas;

        // Set default folder        
        String projectPath = vegas.Project.FilePath;
        _defaultBasePath = String.IsNullOrEmpty(projectPath) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : Path.GetDirectoryName(projectPath);        // Show Dialog
        DialogResult result = ShowBatchRenderDialog();
        _myVegas.UpdateUI();

        if (result == DialogResult.OK)
        {
            try
            {
                SetValue(@"DefaultDirectory", _defaultFolderTextBox.Text);
            }
            catch
            { }

            try
            {
                SetValue(@"Naming", _namingTextBox.Text);
            }
            catch
            { }
            
            // Inform the user of some special failure cases
            String outputFilePath = Path.Combine(_defaultFolderTextBox.Text, GetFileNameFromNaming(_namingTextBox.Text, ""));
            RenderMode renderMode = RenderMode.Project;
            if (_renderRegionsRadioButton.Checked)
            {
                renderMode = RenderMode.Regions;
            }
            else if (_renderSelectionRadioButton.Checked)
            {
                renderMode = RenderMode.Selection;
            }
            
            // Do Rendering
            DoBatchRender(_selectedTemplates, outputFilePath, renderMode);
        }
        if (result == DialogResult.OK && _shutdownCheckbox.Checked && !_canceled)
        {
            ShowShutDownDialog();
        }
    }

    string GetFileNameFromNaming(int regionInt, string regionText, string tempName)
    {
        String tempString = _namingTextBox.Text; tempString = tempString.Replace("[PFNAME]", String.IsNullOrEmpty(_myVegas.Project.FilePath) ? "Untitled" : Path.GetFileNameWithoutExtension(_myVegas.Project.FilePath));
        tempString = tempString.Replace("[RINT]", regionInt.ToString());
        tempString = tempString.Replace("[RTITLE]", regionText);
        tempString = tempString.Replace("[TNAME]", tempName);
        tempString = tempString.Replace("[RINT+1]", (regionInt + 1).ToString()); return FixFileName(tempString);
    }

    string GetFileNameFromNaming(string text, string templName)
    {
        text = text.Replace("[PFNAME]", String.IsNullOrEmpty(_myVegas.Project.FilePath) ? "Untitled" : Path.GetFileNameWithoutExtension(_myVegas.Project.FilePath));
        text = text.Replace("[PFNAME]", Path.GetFileNameWithoutExtension(_myVegas.Project.FilePath));
        text = text.Replace("[RINT]", "");
        text = text.Replace("[RTITLE]", "");
        text = text.Replace("[TNAME]", templName);
        text = text.Replace("[RINT+1]", ""); return FixFileName(text);
    }

    static void Button2Click(object sender, EventArgs e)
    {
        MessageBox.Show("Varialbes to use in naming:\n" +
                        "[PFNAME]: Project File Name (if not saved results in Untitled)\n\n" +
                        "[RINT]: Current region index (is vital when using Render Regions without region titles)\n\n" +
                        "[RINT+1]: Starts calculating region index from 1\n\n" +
                        "[RTITLE]: Current region title (results in error if region titles are the same while not using [RINT])\n\n" +
                        "[TNAME]: Template name (is vital if selected more than one template from the same codec)\n\n");
    }

    void DoBatchRender(ArrayList selectedTemplates, String basePath, RenderMode renderMode)
    {
        String outputDirectory = Path.GetDirectoryName(basePath);

        // make sure templates are selected
        if ((null == selectedTemplates) || (0 == selectedTemplates.Count))
        {
            throw new ApplicationException("No render templates selected.");
        }

        // make sure the output directory exists
        if (!Directory.Exists(outputDirectory))
        {
            throw new ApplicationException("The output directory does not exist.");
        }

        RenderStatus status = RenderStatus.Canceled;

        // Enumerate through each selected render template
        foreach (RenderItem renderItem in selectedTemplates)
        {
            if (renderMode == RenderMode.Regions)
            {
                for (int index = _regionStartIndex - 1; index < _myVegas.Project.Regions.Count; index++)
                {
                    Region region = _myVegas.Project.Regions[index];
                    String regionFilename = GetFileNameFromNaming(_regionStartIndex - 1, region.Label, renderItem.Template.Name) +
                                            renderItem.Extension;
                    
                    // Render the region
                    status = DoRender(regionFilename, renderItem, region.Position, region.Length);
                    if (status == RenderStatus.Canceled)
                    {
                        _canceled = true;
                        break;
                    }
                    _regionStartIndex++;
                }
            }
            else
            {
                String filename = GetFileNameFromNaming(_namingTextBox.Text, renderItem.Template.Name) + renderItem.Extension;

                Timecode renderStart, renderLength;
                if (renderMode == RenderMode.Selection)
                {
                    renderStart = _myVegas.SelectionStart;
                    renderLength = _myVegas.SelectionLength;
                }
                else
                {
                    renderStart = new Timecode();
                    renderLength = _myVegas.Project.Length;
                }
                status = DoRender(filename, renderItem, renderStart, renderLength);
            }
            if (status == RenderStatus.Canceled)
            {
                _canceled = true;
                break;
            }
        }
    }

    RenderStatus DoRender(String filePath, RenderItem renderItem, Timecode start, Timecode length)
    {
        filePath = Path.Combine(_defaultFolderTextBox.Text, filePath); ValidateFilePath(filePath);

        // Make sure the file does not already exist
        if (!_overwriteExistingFile && File.Exists(filePath))
        {
            throw new ApplicationException("File already exists: " + filePath);
        }
        
        // Perform the render
        RenderStatus status = _myVegas.Render(filePath, renderItem.Template, start, length);

        switch (status)
        {
            case RenderStatus.Complete:
            case RenderStatus.Canceled:
                break;
            default:
                StringBuilder msg = new StringBuilder("Render failed:\n");
                msg.Append("\n    file name: ");
                msg.Append(filePath);
                msg.Append("\n    Renderer: ");
                msg.Append(renderItem.Renderer.FileTypeName);
                msg.Append("\n    Template: ");
                msg.Append(renderItem.Template.Name);
                msg.Append("\n    Start Time: ");
                msg.Append(start.ToString());
                msg.Append("\n    Length: ");
                msg.Append(length.ToString());
                throw new ApplicationException(msg.ToString());
        }
        return status;
    }

    private TextBox _defaultFolderTextBox;
    private TextBox _namingTextBox;
    private TreeView _templatesTreeView;
    private RadioButton _renderProjectRadioButton;
    private RadioButton _renderSelectionRadioButton;
    private RadioButton _renderRegionsRadioButton;
    private CheckBox _shutdownCheckbox;
    private Form _dlog;

    DialogResult ShowBatchRenderDialog()
    {
        // Main Form
        _dlog = new Form();
        _dlog.Text = @"Batch Render v2A";
        _dlog.FormBorderStyle = FormBorderStyle.FixedDialog;
        _dlog.MaximizeBox = false;
        _dlog.StartPosition = FormStartPosition.CenterScreen;
        _dlog.Width = 1200;
        _dlog.Height = 886;
        
        // Default Folder Label
        Label label1 = new Label();
        label1.AutoSize = true;
        label1.Location = new Point(24, 18);
        label1.Size = new Size(152, 26);
        label1.Text = @"Default Folder:";
        
        // Default Folder TextBox
        _defaultFolderTextBox = new TextBox();
        _defaultFolderTextBox.Location = new Point(188, 12);
        _defaultFolderTextBox.Size = new Size(794, 40);
        _defaultFolderTextBox.Text = _defaultBasePath;
        
        // Browse Button
        Button button1 = new Button();
        button1.Location = new Point(994, 8);
        button1.Size = new Size(150, 46);
        button1.Text = @"Browse...";
        
        // Naming Label
        Label label2 = new Label();
        label2.AutoSize = true;
        label2.Location = new Point(84, 70);
        label2.Size = new Size(92, 26);
        label2.Text = @"Naming:";
        
        // Naming TextBox
        _namingTextBox = new TextBox();
        _namingTextBox.Location = new Point(188, 64);
        _namingTextBox.Size = new Size(794, 40);
        _namingTextBox.Text = @"[PFNAME]";  
        
        // Templates TreeView
        _templatesTreeView = new TreeView();
        _templatesTreeView.Location = new Point(30, 116);
        _templatesTreeView.Size = new Size(1114, 600);
        _templatesTreeView.CheckBoxes = true;
        
        // Render Project RadioButton
        _renderProjectRadioButton = new RadioButton();
        _renderProjectRadioButton.AutoSize = true;
        _renderProjectRadioButton.Checked = true;
        _renderProjectRadioButton.Location = new Point(30, 728);
        _renderProjectRadioButton.Size = new Size(192, 34);
        _renderProjectRadioButton.Text = @"Render Project";
        
        // Render Selection RadioButton
        _renderSelectionRadioButton = new RadioButton();
        _renderSelectionRadioButton.AutoSize = true;
        _renderSelectionRadioButton.Location = new Point(234, 728);
        _renderSelectionRadioButton.Size = new Size(214, 34);
        _renderSelectionRadioButton.Text = @"Render Selection";
        if (0 == _myVegas.SelectionLength.Nanos) _renderSelectionRadioButton.Enabled = false;
        
        // Render Regions RadioButton
        _renderRegionsRadioButton = new RadioButton();
        _renderRegionsRadioButton.AutoSize = true;
        _renderRegionsRadioButton.Location = new Point(460, 728);
        _renderRegionsRadioButton.Size = new Size(2042, 34);
        _renderRegionsRadioButton.Text = @"Render Regions";
        if (_myVegas.Project.Regions.Count == 0) _renderRegionsRadioButton.Enabled = false;
        _renderRegionsRadioButton.CheckedChanged += RenderRegionsRadioButtonCheckedChanged;
        
        // Shutdown CheckBox
        _shutdownCheckbox = new CheckBox();
        _shutdownCheckbox.AutoSize = true;
        _shutdownCheckbox.Location = new Point(30, 774);
        _shutdownCheckbox.Size = new Size(442, 34);
        _shutdownCheckbox.Text = @"Shutdown PC when rendering completes.";
        
        // Button Variables
        Button button2 = new Button();
        button2.Location = new Point(994, 58);
        button2.Size = new Size(150, 46);
        button2.Text = @"Variables";
        button2.Click += Button2Click;
        
        // Button OK
        Button okButton = new Button();
        okButton.Location = new Point(832, 740);
        okButton.Size = new Size(150, 43);
        okButton.Text = @"OK";
        okButton.DialogResult = DialogResult.OK;
        
        // Button Cancel
        Button cancelButton = new Button();
        cancelButton.Location = new Point(994, 740);
        cancelButton.Size = new Size(150, 46);
        cancelButton.Text = @"Cancel";
        cancelButton.DialogResult = DialogResult.Cancel;
        
        // Set Actions
        button1.Click += HandleBrowseClick;
        _dlog.FormClosing += HandleFormClosing;
        _templatesTreeView.AfterCheck += HandleTreeViewCheck;
        
        // Options Button
        Button optButton = new Button();
        optButton.Location = new Point(670, 740);
        optButton.Size = new Size(150, 46);
        optButton.Text = @"Options";
        optButton.Click += OptButtonClick;
        
        // Test Button
        Button testButton = new Button();
        testButton.Location = new Point(30, 58);
        testButton.Size = new Size(42, 46);
        testButton.Text = @"T";
        testButton.Click += TestButtonClick;
        
        // Add Controls
        _dlog.Controls.Add(label1);
        _dlog.Controls.Add(label2);
        _dlog.Controls.Add(_namingTextBox);
        _dlog.Controls.Add(_renderProjectRadioButton);
        _dlog.Controls.Add(_renderRegionsRadioButton);
        _dlog.Controls.Add(_renderSelectionRadioButton);
        _dlog.Controls.Add(_shutdownCheckbox);
        _dlog.Controls.Add(_templatesTreeView);
        _dlog.Controls.Add(button1);
        _dlog.Controls.Add(cancelButton);
        _dlog.Controls.Add(okButton);
        _dlog.Controls.Add(_defaultFolderTextBox);
        _dlog.Controls.Add(button2);
        _dlog.Controls.Add(optButton);
        _dlog.Controls.Add(testButton); FillTemplateTree();
        
        // Try to read
        try
        {
            if (GetValue(@"DefaultDirectory") != "") _defaultFolderTextBox.Text = GetValue(@"DefaultDirectory");
        }
        catch
        { }

        try
        {
            if (GetValue(@"Naming") != "") _namingTextBox.Text = GetValue(@"Naming");
        }
        catch
        { }

        if (IsAnAdministrator() == "False")
        {
            _shutdownCheckbox.Enabled = false;
            _shutdownCheckbox.Text += @" (No Admin Rights)";
        }        // Show Dialog

        return _dlog.ShowDialog(_myVegas.MainWindow);
    }

    void TestButtonClick(object sender, EventArgs e)
    {
        UpdateSelectedTemplates();

        if (_renderRegionsRadioButton.Checked)
        {
            if (_selectedTemplates.Count > 0)
            {
                MessageBox.Show(GetFileNameFromNaming(0, _myVegas.Project.Regions[0].Label, ((RenderItem)_selectedTemplates[0]).Template.Name) + ((RenderItem)_selectedTemplates[0]).Extension);
            }
            else
            {
                MessageBox.Show(GetFileNameFromNaming(0, _myVegas.Project.Regions[0].Label, "[Template Name]") + @".ext");
            }
        }
        else
        {
            if (_selectedTemplates.Count > 0)
            {
                MessageBox.Show(GetFileNameFromNaming(_namingTextBox.Text, ((RenderItem)_selectedTemplates[0]).Template.Name) + ((RenderItem)_selectedTemplates[0]).Extension);
            }
            else
            {
                MessageBox.Show(GetFileNameFromNaming(_namingTextBox.Text, "[Template Name]") + @".ext");
            }
        }
        _selectedTemplates.Clear();
    }

    private CheckBox _checkBox1;
    void OptButtonClick(object sender, EventArgs e)

    {
        // Main Form
        Form form = new Form();
        form.Text = @"Options";
        form.FormBorderStyle = FormBorderStyle.FixedDialog;
        form.MaximizeBox = false;
        form.StartPosition = FormStartPosition.CenterScreen;
        form.Width = 359;
        form.Height = 121;        // Start Render Label
        Label label1 = new Label();
        label1.AutoSize = true;
        label1.Location = new Point(12, 9);
        label1.Size = new Size(107, 13);
        label1.Text = @"Region Render Start:";
        
        // Domain up Down
        DomainUpDown domainUpDown1 = new DomainUpDown();
        domainUpDown1.Location = new Point(125, 7);
        domainUpDown1.Size = new Size(206, 20);
        domainUpDown1.Text = @"1";
        domainUpDown1.ReadOnly = true;
        
        // Button OK
        Button okButton = new Button();
        okButton.Location = new Point(175, 56);
        okButton.Size = new Size(75, 23);
        okButton.Text = @"OK";
        okButton.DialogResult = DialogResult.OK;
        
        // Button Cancel
        Button cancelButton = new Button();
        cancelButton.Location = new Point(256, 54);
        cancelButton.Size = new Size(75, 23);
        cancelButton.Text = @"Cancel";
        cancelButton.DialogResult = DialogResult.Cancel;
        
        // Auto Overwrite
        _checkBox1 = new CheckBox();
        _checkBox1.AutoSize = true;
        _checkBox1.Location = new Point(15, 33);
        _checkBox1.Size = new Size(160, 17);
        _checkBox1.Text = @"Automatically Overwrite Files";
        _checkBox1.CheckedChanged += CheckBox1CheckedChanged; form.Controls.Add(label1);

        form.Controls.Add(domainUpDown1);
        form.Controls.Add(okButton);
        form.Controls.Add(cancelButton);
        form.Controls.Add(_checkBox1); _checkBox1.Checked = _overwriteExistingFile;

        if (_myVegas.Project.Regions.Count > 0)
        {
            for (int i = 0; i < _myVegas.Project.Regions.Count; i++)
            {
                domainUpDown1.Items.Add((i + 1).ToString()); domainUpDown1.Text = _regionStartIndex == 0 ? @"1" : _regionStartIndex.ToString();
            }
        }
        else
        {
            domainUpDown1.Enabled = false;
        }

        if (form.ShowDialog(_dlog) == DialogResult.OK)
        {
            if (domainUpDown1.Enabled)
            {
                _regionStartIndex = Convert.ToInt32(domainUpDown1.Text);
            }
        }
    }

    void CheckBox1CheckedChanged(object sender, EventArgs e)
    {
        _overwriteExistingFile = _checkBox1.Checked;
    }

    void RenderRegionsRadioButtonCheckedChanged(object sender, EventArgs e)
    {
        if (_renderRegionsRadioButton.Checked && _renderRegionsRadioButton.Enabled)
        {
            _namingTextBox.Text += @"[RINT]";
        }
        else
        {
            _namingTextBox.Text = _namingTextBox.Text.Replace("[RINT]", "");
        }
    }

    void FillTemplateTree()
    {
        int projectAudioChannelCount = 0;

        if (AudioBusMode.Stereo == _myVegas.Project.Audio.MasterBusMode)
        {
            projectAudioChannelCount = 2;
        }
        else if (AudioBusMode.Surround == _myVegas.Project.Audio.MasterBusMode)
        {
            projectAudioChannelCount = 6;
        }

        bool projectHasVideo = ProjectHasVideo();
        bool projectHasAudio = ProjectHasAudio();

        foreach (Renderer renderer in _myVegas.Renderers)
        {
            try
            {
                String rendererName = renderer.FileTypeName;
                TreeNode rendererNode = new TreeNode(rendererName);
                rendererNode.Tag = new RenderItem(renderer, null, null);
                foreach (RenderTemplate template in renderer.Templates)
                {
                    try
                    {
                        // filter out invalid templates
                        if (!template.IsValid())
                        {
                            continue;
                        }
                        // filter out video templates when project has
                        // no video.
                        if (!projectHasVideo && (0 < template.VideoStreamCount))
                        {
                            continue;
                        }
                        // filter out audio-only templates when project has no audio
                        if (!projectHasAudio && (0 == template.VideoStreamCount) && (0 < template.AudioStreamCount))
                        {
                            continue;
                        }
                        // filter out templates that have more channels than the project
                        if (projectAudioChannelCount < template.AudioChannelCount)
                        {
                            continue;
                        }
                        // filter out templates that don't have
                        // exactly one file extension
                        String[] extensions = template.FileExtensions;
                        if (1 != extensions.Length)
                        {
                            continue;
                        }
                        String templateName = template.Name;
                        TreeNode templateNode = new TreeNode(templateName);
                        templateNode.Tag = new RenderItem(renderer, template, extensions[0]);
                        rendererNode.Nodes.Add(templateNode);
                    }
                    catch (Exception e)
                    {
                        // skip it
                        MessageBox.Show(e.ToString());
                    }
                }
                if (0 == rendererNode.Nodes.Count)
                {
                    continue;
                }
                if (1 == rendererNode.Nodes.Count)
                {
                    // skip it if the only template is the project
                    // settings template.
                    if (0 == ((RenderItem)rendererNode.Nodes[0].Tag).Template.Index)
                    {
                        continue;
                    }
                }
                else
                {
                    _templatesTreeView.Nodes.Add(rendererNode);
                }
            }
            catch
            {
                // skip it
            }
        }
    }

    void UpdateSelectedTemplates()
    {
        _selectedTemplates.Clear();
        foreach (TreeNode node in _templatesTreeView.Nodes)
        {
            foreach (TreeNode templateNode in node.Nodes)
            {
                if (templateNode.Checked)
                {
                    _selectedTemplates.Add(templateNode.Tag);
                }
            }
        }
    }

    void HandleBrowseClick(Object sender, EventArgs args)
    {
        FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
        folderBrowserDialog.ShowNewFolderButton = true;
        if (null != _defaultFolderTextBox)
        {
            String initialDir = _defaultFolderTextBox.Text;
            if (Directory.Exists(initialDir))
            {
                folderBrowserDialog.SelectedPath = initialDir;
            }
        }
        if (DialogResult.OK != folderBrowserDialog.ShowDialog()) return; if (null != _defaultFolderTextBox)
        {
            _defaultFolderTextBox.Text = folderBrowserDialog.SelectedPath;
        }
    }

    static void HandleTreeViewCheck(object sender, TreeViewEventArgs args)
    {
        if (args.Node.Checked)
        {
            if (0 != args.Node.Nodes.Count)
            {
                if ((args.Action == TreeViewAction.ByKeyboard) || (args.Action == TreeViewAction.ByMouse))
                {
                    SetChildrenChecked(args.Node, true);
                }
            }
            else if (!args.Node.Parent.Checked)
            {
                args.Node.Parent.Checked = true;
            }
        }
        else
        {
            if (0 != args.Node.Nodes.Count)
            {
                if ((args.Action == TreeViewAction.ByKeyboard) || (args.Action == TreeViewAction.ByMouse))
                {
                    SetChildrenChecked(args.Node, false);
                }
            }
            else if (args.Node.Parent.Checked)
            {
                if (!AnyChildrenChecked(args.Node.Parent))
                {
                    args.Node.Parent.Checked = false;
                }
            }
        }
    }

    void HandleFormClosing(Object sender, FormClosingEventArgs args)
    {
        Form dlg = sender as Form;

        if (null == dlg) return;

        if (DialogResult.OK != dlg.DialogResult) return;

        String outputFilePath = Path.Combine(_defaultFolderTextBox.Text, GetFileNameFromNaming(_namingTextBox.Text, ""));
        try
        {
            String outputDirectory = Path.GetDirectoryName(outputFilePath);
            if (!Directory.Exists(outputDirectory)) throw new ApplicationException();
        }
        catch
        {
            String title = "Invalid Directory";
            StringBuilder msg = new StringBuilder();
            msg.Append("The output directory does not exist.\n");
            msg.Append("Please specify the directory and base file name using the Browse button.");
            MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            args.Cancel = true;
            return;
        }
        try
        {
            String baseFileName = Path.GetFileName(outputFilePath);
            if (String.IsNullOrEmpty(baseFileName)) throw new ApplicationException();
            if (-1 != baseFileName.IndexOfAny(Path.GetInvalidFileNameChars())) throw new ApplicationException();
        }
        catch
        {
            String title = "Invalid Base File Name";
            StringBuilder msg = new StringBuilder();
            msg.Append("The base file name is not a valid file name.\n");
            msg.Append("Make sure it contains one or more valid file name characters.");
            MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            args.Cancel = true;
            return;
        }
        UpdateSelectedTemplates();
        if (0 == _selectedTemplates.Count)
        {
            String title = "No Templates Selected";
            StringBuilder msg = new StringBuilder();
            msg.Append("No render templates selected.\n");
            msg.Append("Select one or more render templates from the available formats.");
            MessageBox.Show(dlg, msg.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            args.Cancel = true;
            return;
        }
    }

    static void SetChildrenChecked(TreeNode node, bool checkIt)
    {
        foreach (TreeNode childNode in node.Nodes)
        {
            if (childNode.Checked != checkIt)
                childNode.Checked = checkIt;
        }
    }

    static bool AnyChildrenChecked(TreeNode node)
    {
        foreach (TreeNode childNode in node.Nodes)
        {
            if (childNode.Checked) return true;
        }
        return false;
    }

    Button _button1;
    readonly Timer _tim = new Timer();
    int _iTime = 0;
    Form _dlog1;

    void ShowShutDownDialog()
    {
        _dlog1 = new Form();
        _dlog1.FormBorderStyle = FormBorderStyle.None;
        _dlog1.MaximizeBox = false;
        _dlog1.StartPosition = FormStartPosition.CenterScreen;
        _dlog1.Width = 600;
        _dlog1.TopMost = true;
        _dlog1.Size = new Size(137, 60);

        Label textLabel = new Label();
        textLabel.AutoSize = true;
        textLabel.Location = new Point(12, 9);
        textLabel.Size = new Size(118, 13);
        textLabel.TabIndex = 0;
        textLabel.Text = @"Shutdown in progress...";
        _dlog1.Controls.Add(textLabel);

        _button1 = new Button();
        _button1.Location = new Point(30, 35);
        _button1.Size = new Size(75, 23);
        _button1.TabIndex = 1;
        _button1.Text = @"Cancel";
        _button1.UseVisualStyleBackColor = true;
        _button1.Click += Button1Click;
        _button1.DialogResult = DialogResult.Cancel;
        _dlog1.Controls.Add(_button1);

        _tim.Interval = 1000;
        _iTime = 0;
        _tim.Tick += TimTick; _tim.Enabled = true;
        _tim.Start(); _dlog1.ShowDialog(_myVegas.MainWindow);
        return;
    }

    void Button1Click(object sender, EventArgs e)
    {
        _tim.Stop();
        _tim.Enabled = false;
    }

    void TimTick(object sender, EventArgs e)
    {
        if (_iTime == 10)
        {
            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\PreShutdownSave.veg"))
            {
                File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\PreShutdownSave.veg"); _myVegas.SaveProject(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\PreShutdownSave.veg");
            }

            _myVegas.Exit();
            Process.Start("Shutdown", "-s -t 10");
            _dlog1.Close();
            _tim.Enabled = false; // DO NOT REMOVE
            _tim.Stop(); // DO NOT REMOVE
        }
        else
        {
            _iTime++;
        }
    }
}

 

 

iEmby wrote on 11/26/2023, 3:18 PM
Is there some way to batch render all the regions in a project and name the files the same name as the regions, in this case, song titles? I went through the trouble of naming all the regions, and then I look in the batch render script and it just gives me the option of a base file name. There's got to be a way to have the region names be the file names for all these MP3 files I'm about to render?

this is just made for u.. have fun
https://www.vegascreativesoftware.info/us/forum/updated-batch-render-script-is-here-download-it-test-it-share-it--142682/

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)