Calculate proxy path

Sometimes, it is only possible to import or use a hires file because no proxy is available, or the functionality to import a hires file with a linked proxy is not accessible due to technical restrictions (e.g., limitations in third-party extensions).

If the proxy path follows a predefined pattern, it is possible to calculate the proxy path and use it for an underlying workflow. While using the path split action node may seem like an easy solution, this approach can fail if the asset path varies due to differing subdirectory depths, resulting in unexpected outcomes.

A more robust solution would be to use JavaScript Nashorn code, which leverages known parameters to identify the path and returns the expected proxy path.

// Input strings
// input path needs to be json escaped (for windows only) or unix if path mapping is in place
// var hiresPath = "{path.map.to.json.{job.source}}";
// var hiresPath = "{path.map.to.unix.{job.source}}";
var hiresPath = "C:\\\\sports\\lucid-production\\Production\\01_Media\\Original_Card_Media\\2024 Card Media\\22_VEG\\Test Rushes_Card 01\\XDROOT\\Clip\\test.mxf";

// Define variables
var hiresDelimiter = "Original_Card_Media";
var proxyDelimiter = "Proxy_Card_Media";
var hiresExtension = "mxf";
var proxyExtension = "mov";

// Function to transform the hiresPath to proxyPath
function transformPath(hiresPath, hiresDelimiter, proxyDelimiter, hiresExtension, proxyExtension) {
    // Replace the hiresDelimiter with proxyDelimiter
    var proxyPath = hiresPath.replace(hiresDelimiter, proxyDelimiter);
    
    // Replace the hiresExtension with proxyExtension
    proxyPath = proxyPath.replace(new RegExp(hiresExtension + '$'), proxyExtension);
    
    return proxyPath;
}

// Transform the path
var proxyPath = transformPath(hiresPath, hiresDelimiter, proxyDelimiter, hiresExtension, proxyExtension);

// Output the result
proxyPath;

Example output path:

C:\sports\lucid-production\Production\01_Media\Proxy_Card_Media\2024 Card Media\22_VEG\Test Rushes_Card 01\XDROOT\Clip\test.mov

Last updated