Quantcast
Channel: Adobe Community : Popular Discussions - Premiere Pro SDK
Viewing all articles
Browse latest Browse all 53010

Regex on getMediaPath issues

$
0
0

Hi all,

 

I'm trying to write a script to automatically attach proxies looking in the Proxies subfolder, with the added "_proxy" suffix and the new file extension (.mp4).

 

Please forgive how ugly this code is but I'm trying to get it working before I refactor it:

 

function attachProxy(file){    if (file.hasProxy() === false){        var mediaPath = file.getMediaPath();        //escape backslash        var mediaPathFix = mediaPath.replace(/\\/g, "\\\\");        // regex to split path into 3: folder + filename + .extension        const splitRegex = /(\w?\:?\\?[\w\-_ \\]*\\+)?([\w-_ ]+)?(\.[\w-_ ]+)?/gi;        var splitNameArray = splitRegex.exec(mediaPathFix); // this is where code goes wrong in the extension, even though it's fine in browser console        var proxyPath = splitNameArray[1] + "Proxies\\\\" + splitNameArray[2] + "_Proxy" + ".mp4";        file.attachProxy(proxyPath, 0);        alert("proxy has been attached");    } else {        alert("proxy attached already");    }
}

 

My issue is that I've managed to make this work in the Chrome console, by giving the mediaPath variable a value manually:

 

mediaPath = "D:\\Al Sahel\\CLIPS\\Drone\\Mountain Bikes\\DJI_0033.MOV"

 

this returns a proxy path of:

 

proxyPath = "D:\\Al Sahel\\CLIPS\\Drone\\Mountain Bikes\\Proxies\\DJI_0033_Proxy.mp4"

 

But once I test it in the JSX file (through JSX Launcher), the splitName array doesn't look correct, just returning "D".

 

I'm guessing this is to do with escaping backslashes, but I'm not sure where my issue is. I also didn't write the Regex myself so this makes it harder to troubleshoot.

 

Thanks for your help!


Viewing all articles
Browse latest Browse all 53010

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>