ChangeRenderOutputPaths Script
From The Foundry MODO SDK wiki
Revision as of 23:06, 1 April 2012 by Jangell (Talk | contribs) (Created page with "This script loops through all render output items and changes their paths. The original filename is appended to the new path. Be sure to include the trailing slash at the end ...")
This script loops through all render output items and changes their paths. The original filename is appended to the new path. Be sure to include the trailing slash at the end of the new path.
@ChangeRenderOutputPaths.pl C:\New\Path\
The script loops through all items looking for render output items. For each one found, it grabs the original path, uses regular expressions to split out the filename, appends it to the new path, and updates the item’s channel.
# perl
# ChangeRenderOutputPaths.pl
# Joe Angell, Luxology LLC
# Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
# Patents pending.
#
# Changes the output paths of all render output items
# in the scene
# Make sure we have our arguments
if( $#ARGV + 1 != 1 ) {
lxout( "Usage: \@ChangeRenderOutputPaths.pl new/output/path/" );
lxout( "Changes all render output item paths to the provided path with the original filename." );
lxout( "The argument is the new path, which must include the trailing slash." );
die( "Missing required new path argument" );
}
my $filenamePart;
# Get the item count
my $n = lxq( "query sceneservice item.N ?" );
# Loop through the items in the scene, looking for output items
for( $i=0; $i < $n; $i++ ) {
my $type = lxq( "query sceneservice item.type ? $i" );
if( $type eq "renderOutput" ) {
# Get the item ID
$itemID = lxq( "query sceneservice item.id ? $i" );
lxout( "Item ID: $itemID" );
# Select the item
lx( "select.item $itemID" );
# Get the original path
my $originalPath = lxq( "item.channel renderOutput\$filename ?" );
# If the path is empty, skip it
if( !$originalPath ) {
next;
}
# Split the path from the filename using regex
my @pathParts = split( /\/|\\/, $originalPath );
if( @pathParts == 0 ) {
# Nothing to split; path must consist of
# just the filename
$filenamePart = $originalPath;
} else {
$filenamePart = $pathParts[ @pathParts - 1 ];
}
# Combine the passed in path with the original filename
$newPath = $ARGV[0] . $filenamePart;
lx( "item.channel renderOutput\$filename {$newPath}" );
}
}