I need a really simple script that exports the filenames of my project media as a list that I can drop into a spreadsheet. The output would be a text file like this:
Are you sure you just want the file names without the full path? This will do what you asked for (just the names). I can modify it to use the complete path if you'd like. It saves the file in the same folder as your project:
//**************************************************************
//* Program: MediaNamesToFile.cs
//* Author: John Rofrano
//* Description: Dumps the media pool file names to a file
//* Last Updated: March 28, 2010
//* Copyright: (c) 2010 VASST, All Rights Reserved
//**************************************************************
using System;
using System.IO;
using System.Collections;
using System.Windows.Forms;
using Sony.Vegas;
class EntryPoint
{
public void FromVegas(Vegas vegas)
{
try
{
// make sure we have a path to save to
if (vegas.Project.FilePath == null || vegas.Project.FilePath == String.Empty)
{
throw new Exception("You must save your project before running this script");
}
// build a filename in the project folder
string filename = Path.Combine(Path.GetDirectoryName(vegas.Project.FilePath), "MediaFileList.txt");
// iterate through the media pool and get the media filenames
TextWriter file = new StreamWriter(filename);
foreach (Media media in vegas.Project.MediaPool)
{
// write anything that isn't a generated media, a subclip, or image sequence
if (!media.IsGenerated() && !media.IsSubclip() && !media.IsImageSequence())
{
file.WriteLine(Path.GetFileName(media.FilePath));
}
}
file.Close();
// let the user know we are done
MessageBox.Show(String.Format("File saved as: {0}", filename), "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}