D'oh! Never mind...
I was taking some screen shots to illustrate the issue and found the template name is now appearing in the script's list. I triple checked that yesterday...maybe Vegas needed to be restarted?
Good thing I don't have to change the file names...I've rendered 36, so far.
Ok, I purchased the Render Assistant, looks like a nice tool so far!
John, is there a way I can re-download Render Assistant? I have a need for it again but cannot locate it anywhere on my computer. My order number is 16953954-YQHH Thanks!
EDIT: I just found the setup file. It's version 1.0.2 When I try to run it, it says it requires Vegas Pro 9.0a or greater. This doesn't make sense as I have v13. Is there a newer version than 1.0.2?
I have a script that I have updated for Vegas 14 that allows Batch render with the option of names the files with the region names.
Batch Render 5 Magix.csI also have a script allows batch multiple projects, with redner regions as well
Multiple Project Render Magix.csExport Markers for DVD-A
Export Markers For DVD-A Magix.js
THANK YOU SO MUCH FOR THIS!!!!!!!!! I just upgraded to VP15 (from 13) and my old scripts didn't work. This one does. Thanks again!
I have a script that I have updated for Vegas 14 that allows Batch render with the option of names the files with the region names.
Batch Render 5 Magix.csI also have a script allows batch multiple projects, with redner regions as well
Multiple Project Render Magix.csExport Markers for DVD-A
Export Markers For DVD-A Magix.js
Thank you man, this was able to update Vegas 12 Batch script to my now updated Vegas 16 Batch script. Thanks again!
Thank you for your kind comments in the scripts
Sorry I didn't get back to you sooner. I wish these forums had some kind of email notification.
Yes, Render Assistant definitely uses the region names as the filenames. I wrote it so if you have any questions or requests I'd be happy to discuss them with you.
Thanks for purchasing. :)
~jr
Hi
I know the topic is old but I have a question!
When I run the Batch Render with Name Regions script, the files are created correctly and, when I open the Windows Media Player songs, they play without pauses and I can jump between tracks, this is perfect!
But when I play the songs on my dvd player, do they pause between songs?! ... How can I make the songs play on my dvd player without these pauses like in Windows Media Player?
Thank's
http://forum.gameanyone.com/index.php?topic=13426.10 no longer exists, so I'm posting the code of the SkrowTox's "Batch Render v2" script here for @Javadarsena and anyone else who wants it.
Save this text as "Batch Render v2.cs" and put it in your Documents\Vegas Script Menu\ folder.
When you run the script, select "Render regions" at the bottom and use [RTITLE] as the "Naming" variable, to use the region names as the rendered filenames.
/* 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++;
}
}
...
"Hello, I use the GPT chat translator to respond. Thank you for the reply. I'm not sure how to do that, but I'll try. Is there any video tutorial? It would be easier. How do I paste that? In a text document? I can't find that folder in my version of Vegas (Pro 21 build 187). I only have folders for File Drop, Mobile Upload, VEGAS Content, and VEGAS Projects. I'll try, but I'm not sure how to do it. Thanks for the reply."
@NickHope Hi, can you explain this pls? When i write [RTITLE] it names the rendered files [RTITLE] 1 [RTITLE] 2 etc.. 😂 There's no option to choose that option 🤷♂️
@Former user Just delete "[PFNAME][RINT]" in the "Naming" field and write "[RTITLE]" there instead.
...How do I paste that? In a text document?...
@Javadarsena You can do it in Notepad.
...I can't find that folder in my version of Vegas (Pro 21 build 187)...
Create a folder named "Vegas Script Menu" in your Windows "Documents" folder. Any recent version of VEGAS Pro will read the scripts in it. Alternatively you can put them in the "C:\Program Files\VEGAS\VEGAS Pro 21.0\Script Menu" folder but you will need to put them in that folder for each major version of VEGAS Pro.
@NickHope Thanks, I deleted my comment because i worked it out, I was typing [RITTLE] or {RTITLE}, basically it was user error, bit dark in here without the lamp on 👴🧐🤦♂️😂👍
It is much easier to place your modified scripts in:
[My Documents}\Vegas Script Menu
Then every version of VEGAS you have installed will see them AND you won't be modifying the "Program Files" folder.
Also:
/* Batch Render v2 by SkrowTox */ /* Update 0 */using System; using System.Collections;
should be
/* Batch Render v2 by SkrowTox */ /* Update 0 */ using System; using System.Collections;
There's also a modified Batch Render version here:
I've deleted my comment to save from confusion,
Also:
/* Batch Render v2 by SkrowTox */ /* Update 0 */using System; using System.Collections;should be
/* Batch Render v2 by SkrowTox */ /* Update 0 */ using System; using System.Collections;
@jetdv Hi, this script above seems to work, so what does moving 'using system' change?
And a reminder: I recently edited the batch render v2 script to increase the size of the menu:
https://www.vegascreativesoftware.info/us/forum/batch-render-v2-menu-size-mod--140979/
@Former user, yes it will work as the script really doesn't care about linefeeds and the "using" is, technically, after the comment. It's more for readability. The first way it appears the "using" is part of the comment (even though it's really "after" the comment) and could be easily overlooked as being there.
I like readability... That's why I also like proper indentation - which, once again - technically - the script above does not have. Here's another example:
return;
} void Button1Click(object sender, EventArgs e)
{
_tim.Stop();
_tim.Enabled = false;
} void TimTick(object sender, EventArgs e)
{
is much more readable as:
return;
}
void Button1Click(object sender, EventArgs e)
{
_tim.Stop();
_tim.Enabled = false;
}
void TimTick(object sender, EventArgs e)
{
That way the function names stick out better and are easier to find and the beginning and the end of the routines are also better defined. I can't guarantee I caught them all but this version is much more readable:
/* 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++;
}
}
}
@jetdv Thankyou for explaining that 👍
I have my own doctored batch render script linked in my profile which I originally cooked up back in the Sony days. It doesn't change much except defaulting to regions and using the region names to name the files, preceded by a 3-digit number which preserves the order of the regions as they exist in the project. Having migrated this script over the years, I've found it helpful to comment out the changes I've made with marked replacement code... making it easier for me to conform the script to changes Vegas has made in their distribution. I've been using this version since vp16. Been contemplating an enhancement to optionally de-select regions with check-boxes while dll'ing it in Visual Studio, but never seem to get around to it.
@Former user, yes i
...
Very good, is there any video tutorial? I haven't been able to do it with any method. I have Vegas 21
I like readability... That's why I also like proper indentation - which, once again - technically - the script above does not have.
@jetdv When I copied the code in Vscode and pasted it in a code block here, the line feeds were not interpreted as line feeds, so I had to paste into Notepad first then copy from there to here. I think that's where some of the ugly formatting got introduced. Apologies and thanks for your improved version.
And a reminder: I recently edited the batch render v2 script to increase the size of the menu:
https://www.vegascreativesoftware.info/us/forum/batch-render-v2-menu-size-mod--140979/
@3d87c4 The changes you made are already in the scripts that I and jetdv posted above.
So, to be clear, if someone wants to use the SkrowTox script, it's now recommended to use the text from jetdv's comment above: https://www.vegascreativesoftware.info/us/forum/batch-render-regions-to-filenames--94424/?page=2#ca898340
@NickHope, I've seen some nasty formatting when copying from the website. Fortunately, pasting into Visual Studio seems to work well at keeping for formatting. Copying from one post to another post loses all carriage returns. Never tried pasting into VSCode as I like the code completion available in Visual Studio. The only place I've used VSCode is with Premiere scripts.
And I did notice one thing I missed above:
if (IsAnAdministrator() == "False")
{
_shutdownCheckbox.Enabled = false;
_shutdownCheckbox.Text += @" (No Admin Rights)";
} // Show Dialog
return _dlog.ShowDialog(_myVegas.MainWindow);
}
should have been (Didn't notice the "comment" after the line when I quickly went through to do the reformatting):
if (IsAnAdministrator() == "False")
{
_shutdownCheckbox.Enabled = false;
_shutdownCheckbox.Text += @" (No Admin Rights)";
}
// Show Dialog
return _dlog.ShowDialog(_myVegas.MainWindow);
}
Will it make a difference to the script? No. Does it better tell you what that line is doing? Yes.
@NickHope, @jetdv,
Have you noticed the problem with the left edge of the naming text field? The left edge of the text field obscures the bracket, i.e. [, of the name. It's there, but not visible. I usually leave [PFNAME] as is, but noticed the hidden bracket recently when I entered something different.
I never took the time to sort this out, sorry.
@3d87c4 I don't get that, my whole window looks a bit different to yours though, you've got rounded corners on the window & boxes, as you say the Naming at the top covers [PFNAME] & render options at the bottom cover the 'Options' box, I guess yours is a different script?
@Former user: D'oh! I hadn't noticed what's going on at the bottom of the menu.
Are you on W10 or W11? I'm on W11.
I have 3 different versions of this script on my system & unfortunately the version revision text on the menu box hasn't been edited.
Version 2A (By my reconning) is the version modified to run in the Magix code.
I did a crude edit to the menus (basically just doubling the dimensions of everything) and saved it as 2B. I had to do this because I couldn't read the menu on my laptop computer's small high resolution monitor.
I installed the version being discussed by @NickHope and @jetdv today and have named it 2C on my computer. The menu's for my version 2B and 2C look the same on my screen.
Are you running on a desktop computer with a large monitor?