Here's the script Shaun asked for. It's a very simple script that doesn't have all the functionality he wanted, but maybe someone else can contribute. It has no real errorchecking at the moment, and something seems odd about TimecodeOut. It doesn't correspond to the TimecodeOut you see in the Media Pool, maybe what we see there is Length - TimecodeOut?
I chose HTML for the output, because that's the only easy way I could think of to get a nice table with variable width. If I'd done a textfile it would have had to be with a monotyped font with fixed fieldwidths.
Note that horizontal tabs have been replaced with nonbreaking spaces to keep the indenting in the code, otherwise it disappears when you post on this forum. This makes the HTML output a bit bigger than it has to be.
-----------------------
import System.Text;
import System.IO;
import System.Windows.Forms;
import SonicFoundry.Vegas.Script;
var mediaEnum = new Enumerator(Vegas.Project.MediaPool);
if (mediaEnum.atEnd())
{
MessageBox.Show("There is no media in this project.");
}
else
{
var output : StringBuilder = new StringBuilder();
output.Append("<TABLE BORDER=\"1\" CELLPADDING=\"4\" CELLSPACING=\"0\">\n");
output.Append(" <TR>\n");
output.Append(" <TH>\n");
output.Append(" Name\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" Comment\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" TimecodeIn\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" TimecodeOut\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" Length\n");
output.Append(" </TH>\n");
output.Append(" </TR>\n");
while (!mediaEnum.atEnd())
{
output.Append(" <TR>\n");
var media = mediaEnum.item();
output.Append(" <TD>\n " + media.FilePath + "\n </TD>\n");
output.Append(" <TD>\n " + media.Comment + "\n </TD>\n");
output.Append(" <TD>\n " + media.TimecodeIn + "\n </TD>\n");
output.Append(" <TD>\n " + media.TimecodeOut + "\n </TD>\n");
output.Append(" <TD>\n " + media.Length + "\n </TD>\n");
mediaEnum.moveNext();
output.Append(" </TR>\n");
}
output.Append("</TABLE>\n");
var filename : String = SaveAs()
if (filename != "") WriteFile(filename, output.ToString());
}
function SaveAs()
{
var saveFileDialog1 : SaveFileDialog = new SaveFileDialog();
saveFileDialog1.DefaultExt = "html";
saveFileDialog1.Filter = "HTML (*.html)|*.html";
saveFileDialog1.Title = "Save Media Pool List as";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
return saveFileDialog1.FileName;
}
else
{
return "";
}
}
function WriteFile(fileName, content)
{
var writer : StreamWriter = new StreamWriter(fileName);
writer.WriteLine(content);
writer.Close();
}
I chose HTML for the output, because that's the only easy way I could think of to get a nice table with variable width. If I'd done a textfile it would have had to be with a monotyped font with fixed fieldwidths.
Note that horizontal tabs have been replaced with nonbreaking spaces to keep the indenting in the code, otherwise it disappears when you post on this forum. This makes the HTML output a bit bigger than it has to be.
-----------------------
import System.Text;
import System.IO;
import System.Windows.Forms;
import SonicFoundry.Vegas.Script;
var mediaEnum = new Enumerator(Vegas.Project.MediaPool);
if (mediaEnum.atEnd())
{
MessageBox.Show("There is no media in this project.");
}
else
{
var output : StringBuilder = new StringBuilder();
output.Append("<TABLE BORDER=\"1\" CELLPADDING=\"4\" CELLSPACING=\"0\">\n");
output.Append(" <TR>\n");
output.Append(" <TH>\n");
output.Append(" Name\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" Comment\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" TimecodeIn\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" TimecodeOut\n");
output.Append(" </TH>\n");
output.Append(" <TH>\n");
output.Append(" Length\n");
output.Append(" </TH>\n");
output.Append(" </TR>\n");
while (!mediaEnum.atEnd())
{
output.Append(" <TR>\n");
var media = mediaEnum.item();
output.Append(" <TD>\n " + media.FilePath + "\n </TD>\n");
output.Append(" <TD>\n " + media.Comment + "\n </TD>\n");
output.Append(" <TD>\n " + media.TimecodeIn + "\n </TD>\n");
output.Append(" <TD>\n " + media.TimecodeOut + "\n </TD>\n");
output.Append(" <TD>\n " + media.Length + "\n </TD>\n");
mediaEnum.moveNext();
output.Append(" </TR>\n");
}
output.Append("</TABLE>\n");
var filename : String = SaveAs()
if (filename != "") WriteFile(filename, output.ToString());
}
function SaveAs()
{
var saveFileDialog1 : SaveFileDialog = new SaveFileDialog();
saveFileDialog1.DefaultExt = "html";
saveFileDialog1.Filter = "HTML (*.html)|*.html";
saveFileDialog1.Title = "Save Media Pool List as";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
return saveFileDialog1.FileName;
}
else
{
return "";
}
}
function WriteFile(fileName, content)
{
var writer : StreamWriter = new StreamWriter(fileName);
writer.WriteLine(content);
writer.Close();
}