Batch Archive Projects

johnmeyer wrote on 5/24/2005, 6:08 PM
This is a quick and dirty project archiver. It lets you select VEG files -- as many as you want, anywhere on your computer or network -- and it then archives each VEG file and all the media files it points to. These files are trimmed and then copied to the directory you specify in the script. (Sorry, I was lazy, so the output drive/directory is hard-wired. If someone wants to add a little code to let the user specify the output directory at run-time, that would be a nice addition).

Unfortunately, Vegas (including version 6) does not let you specify, via script, the amount of additional media you want to include when the media is trimmed. Thus, only the media actually used by the project is saved -- all other frames of video and all additional audio is not copied. This saves lots of space, but if you need to later use these archives, you will not be able to add additional frames that were in the original source files. Probably not a big deal for most people. The key thing is that, using this script, you can easily archive LOTS of projects all at once.

Each project is saved in a separate directory which is created under the master directory. The directory names are simply the same name as the original VEG file. Of course if you have VEG files that have the same name (in different directories), you won't be able to archive them using this script.

Thus, just to be clear on what this script does, if you have these VEG files:

Wedding 01.veg
Football 03.veg
Airplane ride 14.veg

in various directories, and you specify

H:\Vegas files\Archives 03

as the output directory, then this script will create these directories:

H:\Vegas files\Archives 03\Wedding 01
H:\Vegas files\Archives 03\Football 03
H:\Vegas files\Archives 03\Airplane ride 14

and put the corresponding VEG file and all of its trimmed media files into these directories.

[Edit]
You can download this at Ed Troxel's site (jetdv):

Batch Archive Script

/**
* This script archives all VEG files that you select.
* These VEG files, and all the media contained in each VEG project, are then trimmed and archived to
* individual folders in the directory specified below.
* (Sorry, this directory is hard-wired in this version of the script, so you have to edit the
* script to change it).
*
* Due to limitations in Vegas scripting (which is still a limitation in Vegas 6) you can't
* specify a "head/tail" amount to add to trimmed media.
*
* To change the output directory, edit the "defaultOutputDir" variable below.
*
* John H. Meyer 5/24/2005
* Based on several scripts by other authors
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

// Set this to a valid output directory.
var defaultOutputDir = "H:\\Senior Video veg backups (8)";

// Set the following variable to true if you want to allow the script
// to overrwite existing archived output files (this flag makes the script look only at the
// "veg" file, not at the other files in the output directory).

var allowFileOverwrites = false;


try {

if ((null != defaultOutputDir) && !Directory.Exists(defaultOutputDir))
throw "output directory does not exist: " + defaultOutputDir;

// prompt user for the list of project files to be archived.
var archiveQueue = new Array();
var queueIndex = 0
while (true) {
var nextVeg = ShowOpenFileDialog("Vegas Projects (*.veg)|*.veg", "Select Project Files (click cancel to begin)", null);

if (null == nextVeg) {
break;
}
archiveQueue[queueIndex] = nextVeg;
queueIndex++;
}

// for each project file in the queue...
var archiveIndex = 0
while (archiveIndex < queueIndex) {
// open the next project
var vegFilename = archiveQueue[archiveIndex];
if (!Vegas.OpenProject(vegFilename)) {
throw "failed to open project file: " + vegFilename;
}

// create the output file name (same as veg file name)
var outputName = Path.GetFileNameWithoutExtension(vegFilename);

// compute the output directory for this archive (same as veg file name)
var outputDir = defaultOutputDir + Path.DirectorySeparatorChar + outputName;
var outputFilename = outputDir + Path.DirectorySeparatorChar + outputName + ".veg";
if ((!allowFileOverwrites) && File.Exists(outputFilename))
throw "file already exists: " + outputFilename;

if ( !Directory.Exists(outputDir) ) {
Directory.CreateDirectory(outputDir);
}

// Archive the project
Vegas.ArchiveProject (outputFilename);

archiveIndex++;
}

} catch (e) {
if (!e.skipMessageBox)
MessageBox.Show(e);
}



function ShowOpenFileDialog(filter, title, defaultFilename) {
var openFileDialog = new OpenFileDialog();
if (null == filter) {
filter = "All Files (*.*)|*.*";
}
openFileDialog.Filter = filter;
if (null != title) openFileDialog.Title = title;
openFileDialog.CheckPathExists = true;
openFileDialog.AddExtension = true;
if (null != defaultFilename) {
var initialDir = Path.GetDirectoryName(defaultFilename);
if (Directory.Exists(initialDir)) {
openFileDialog.InitialDirectory = initialDir;
}
openFileDialog.DefaultExt = Path.GetExtension(defaultFilename);
openFileDialog.FileName = Path.GetFileName(defaultFilename);
}
if (System.Windows.Forms.DialogResult.OK == openFileDialog.ShowDialog()) {
return Path.GetFullPath(openFileDialog.FileName);
} else {
return null;
}
}



Comments

No comments yet - be the first to write a comment...