Export project media to text list for spreadsheet?

NickHope wrote on 3/27/2010, 11:59 PM
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:


filename1.avi
filename2.m2t
filename3.m2t
filename4.avi
filename5.m2t
etc....


I had a go at simplifying Export EDL.js but I'm out of my depth.

Can anyone help with this?

Thanks!

Comments

JohnnyRoy wrote on 3/28/2010, 8:22 AM
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);
}
}

}

~jr
NickHope wrote on 3/28/2010, 7:41 PM
Perfect JR Sir! That's exactly what I needed. You've saved me a lot of hassle with this. Thank you very much indeed!

Nick
JohnnyRoy wrote on 3/31/2010, 10:12 AM
Nick, you're very welcome. Glad I could help.

~jr