trialed windows file path issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @description a script with a UI that will automate rendering process for multiple screens
|
||||
* @name show-render-helper
|
||||
* @name Show Render Helper
|
||||
* @author Kyle Harter <kylenmotion@gmail.com>
|
||||
*
|
||||
* @license This script is provided "as is," without warranty of any kind, expressed or implied. In
|
||||
@@ -23,7 +23,7 @@
|
||||
//@include "../library/OS.jsx";
|
||||
//@include "../library/json2.js"
|
||||
|
||||
var versionNumber = '0.1.2';
|
||||
var versionNumber = '0.1.4';
|
||||
var scriptName = "Show Render Helper" + ' v' + versionNumber;
|
||||
|
||||
createUI(thisObj)
|
||||
@@ -49,10 +49,11 @@
|
||||
proj = app.project;
|
||||
}
|
||||
|
||||
var defaultFolder = proj && proj.file ? new Folder(proj.file.parent.absoluteURI + '/renders') : Folder.desktop
|
||||
|
||||
var DEFAULT_SETTINGS = {
|
||||
settings:{
|
||||
defaultOutputPath: proj && proj.file ? proj.file.parent.fsName + separator + 'renders' : Folder.desktop.fsName,
|
||||
defaultOutputPath: defaultFolder.absoluteURI,
|
||||
qcExports : true
|
||||
}
|
||||
}
|
||||
@@ -158,7 +159,7 @@
|
||||
var locationButton = locationPanel.add("button", undefined, undefined, {name: "locationButton"});
|
||||
locationButton.text = "Choose Location...";
|
||||
var renderLocationText = locationPanel.add("statictext", undefined, undefined, {name: "renderLocationText"});
|
||||
renderLocationText.text = truncateFilePath(DEFAULT_SETTINGS.settings.defaultOutputPath, separator);
|
||||
renderLocationText.text = truncateFilePath(Folder.decode(DEFAULT_SETTINGS.settings.defaultOutputPath), separator);
|
||||
renderLocationText.characters = 25;
|
||||
|
||||
|
||||
@@ -167,6 +168,8 @@
|
||||
renderPanel.alignChildren = ['fill', 'top'];
|
||||
renderPanel.margins = panelMargins;
|
||||
var renderButton = renderPanel.add("button", undefined, 'Render', {name: "renderButton"});
|
||||
//<------ TEST ------->
|
||||
// Button used for spot bug testing to avoid going through entire render process
|
||||
// var testButton = renderPanel.add("button", undefined, 'Test', {name: "renderButton"});
|
||||
|
||||
|
||||
@@ -210,7 +213,7 @@
|
||||
var settingsLocationButton = settingsLocationPanel.add("button", undefined, undefined, {name: "settingsLocationButton"});
|
||||
settingsLocationButton.text = "Choose Default Location...";
|
||||
var settingsLocationText = settingsLocationPanel.add("statictext", undefined, undefined, {name: "settingsLocationText"});
|
||||
settingsLocationText.text = truncateFilePath(DEFAULT_SETTINGS.settings.defaultOutputPath, separator);
|
||||
settingsLocationText.text = truncateFilePath(Folder.decode(DEFAULT_SETTINGS.settings.defaultOutputPath), separator);
|
||||
|
||||
var settingsQCPanel = settingsGroup.add('panel', undefined, undefined);
|
||||
settingsQCPanel.orientation = 'column'
|
||||
@@ -226,33 +229,51 @@
|
||||
// saveSettingsPanel.alignment = ['fill', 'bottom'];
|
||||
saveSettingsPanel.alignChildren = ['fill', 'fill'];
|
||||
saveSettingsPanel.margins = panelMargins;
|
||||
var revealSettingsButton = saveSettingsPanel.add("button", undefined, undefined, {name: "saveSettingsButton"});
|
||||
revealSettingsButton.text = "Reveal Settings";
|
||||
var saveSettingsButton = saveSettingsPanel.add("button", undefined, undefined, {name: "saveSettingsButton"});
|
||||
saveSettingsButton.text = "Save Settings";
|
||||
|
||||
//<------ TEST ------->
|
||||
// Event handler used for spot bug testing to avoid going through entire render process
|
||||
/* testButton.addEventListener('mousedown', function(){
|
||||
var renderFolder = new Folder(renderFolderPath);
|
||||
var test = renderFolder;
|
||||
alert(test.toString())
|
||||
}) */
|
||||
|
||||
|
||||
revealSettingsButton.addEventListener('mousedown', function(){
|
||||
var settingsFolder = getSettingsFolder();
|
||||
return settingsFolder.execute()
|
||||
})
|
||||
|
||||
settingsLocationButton.addEventListener('mousedown', function(){
|
||||
var updatedDefaultLocation = Folder.selectDialog('Select a default output location');
|
||||
var settingsLocation = updatedDefaultLocation.absoluteURI;
|
||||
var settingsDisplay = Folder.decode(settingsLocation);
|
||||
if(updatedDefaultLocation !== null){
|
||||
var truncatedDisplayText = truncateFilePath(updatedDefaultLocation.fsName, separator);
|
||||
var truncatedDisplayText = truncateFilePath(settingsDisplay, separator);
|
||||
settingsLocationText.text = truncatedDisplayText;
|
||||
renderLocationText.text = truncatedDisplayText;
|
||||
DEFAULT_SETTINGS.settings.defaultOutputPath = updatedDefaultLocation.fsName
|
||||
DEFAULT_SETTINGS.settings.defaultOutputPath = updatedDefaultLocation.absoluteURI
|
||||
}
|
||||
return
|
||||
})
|
||||
|
||||
function syncQCExports(newVal){
|
||||
settingsQCCB.value = newVal;
|
||||
qcExports.value = newVal;
|
||||
DEFAULT_SETTINGS.settings.qcExports = newVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description updates QC checkbox in UI
|
||||
*/
|
||||
settingsQCCB.onClick = function(){
|
||||
qcExports.value = settingsQCCB.value;
|
||||
DEFAULT_SETTINGS.settings.qcExports = settingsQCCB.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description saves settings to settings file on disk
|
||||
*/
|
||||
|
||||
saveSettingsButton.addEventListener('mousedown', function(){
|
||||
saveSettingsButton.text = 'Saving...'
|
||||
if(writeSettingsFile(DEFAULT_SETTINGS)){
|
||||
@@ -261,14 +282,17 @@
|
||||
saveSettingsButton.text = "Save Settings"
|
||||
})
|
||||
|
||||
|
||||
// Opens URL in browser for AOM file
|
||||
/**
|
||||
* @description opens default browser to reveal output module location on GDrive
|
||||
*/
|
||||
|
||||
omSourceButton.addEventListener('mousedown', function(){
|
||||
var userOS = OS;
|
||||
var launchCode = userOS.openUrl("https://drive.google.com/file/d/1c7ezAQF5_Sy-e0WlRHLGbPluproroBw1/view")
|
||||
})
|
||||
|
||||
|
||||
|
||||
helpEditText.text = setHelpMessage(scriptName, versionNumber);
|
||||
|
||||
|
||||
@@ -276,7 +300,9 @@
|
||||
var bottomWalls = rightColumn.children;
|
||||
var wallsArray = [topWalls[0], topWalls[1], bottomWalls[0], bottomWalls[1]];
|
||||
|
||||
|
||||
/**
|
||||
* @description selects or deselects all wall checkboxes
|
||||
*/
|
||||
allWalls.onClick = function(){
|
||||
|
||||
if(allWalls.value == false){
|
||||
@@ -291,24 +317,24 @@
|
||||
|
||||
var renderFolderPath = DEFAULT_SETTINGS.settings.defaultOutputPath;
|
||||
|
||||
function truncateFilePath(filePathString, separator) {
|
||||
var pathArray = filePathString.split(separator);
|
||||
var startString = pathArray.slice(0, 1).join(separator);
|
||||
var endString = pathArray.slice(-2,pathArray.length).join(separator);
|
||||
|
||||
var outputString = '...' + separator + endString + separator;
|
||||
return outputString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description sets location of parent output folder
|
||||
*/
|
||||
locationButton.addEventListener('mousedown', function(){
|
||||
var renderFolder = Folder.selectDialog('Select render destination');
|
||||
if(renderFolder !== null){
|
||||
renderFolderPath = renderFolder.fsName;
|
||||
var outputString = truncateFilePath(renderFolderPath, separator)
|
||||
renderFolderPath = renderFolder.absoluteURI;
|
||||
var displayFolderPath = Folder.decode(renderFolderPath)
|
||||
var outputString = truncateFilePath(displayFolderPath, separator)
|
||||
renderLocationText.text = outputString
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* @description begins render process and post-reender actions
|
||||
*/
|
||||
|
||||
renderButton.onClick = function(){
|
||||
try {
|
||||
app.beginUndoGroup("Renders Comps");
|
||||
@@ -353,14 +379,12 @@ function truncateFilePath(filePathString, separator) {
|
||||
}
|
||||
|
||||
|
||||
if(!Folder.renderFolderPath){
|
||||
renderFolderPath = new Folder(renderFolderPath);
|
||||
if(!renderFolderPath.exists){
|
||||
renderFolderPath.create()
|
||||
}
|
||||
var renderFolder = new Folder(renderFolderPath);
|
||||
if(!renderFolder.exists){
|
||||
renderFolder.create()
|
||||
}
|
||||
|
||||
if(renderFolderPath == '') {
|
||||
if(renderFolder.absoluteURI == '') {
|
||||
alert('Whoops!\rYou don\'t have a folder destination selcted. Select one and try again.');
|
||||
return
|
||||
}
|
||||
@@ -387,7 +411,7 @@ function truncateFilePath(filePathString, separator) {
|
||||
}
|
||||
}
|
||||
|
||||
var renderPipeline = buildRenderPipeline(renderComps,renderQueue,templateArray,renderFolderPath);
|
||||
var renderPipeline = buildRenderPipeline(renderComps,renderQueue,templateArray,renderFolder);
|
||||
// RENDERRRRR //
|
||||
app.endUndoGroup()
|
||||
|
||||
@@ -415,14 +439,14 @@ function truncateFilePath(filePathString, separator) {
|
||||
}
|
||||
|
||||
if(completedComps.length > 0){
|
||||
var baseOutputAlert = 'Success!\rYour files were exported to:\r\r' + renderFolderPath.toString() + '\r\r';
|
||||
var baseOutputAlert = 'Success!\rYour files were exported to:\r\r' + Folder.decode(renderFolderPath) + '\r\r';
|
||||
if(qcExports.value){
|
||||
var aeFolders = createImportFolders('zz_QC', completedComps, km.getOrCreateFolder);
|
||||
alert(baseOutputAlert += 'Your exports will be imported into AE inside the folder named zz_QC for quality control');
|
||||
importExportsIntoAE(proj, aeFolders, renderFolderPath, renderPipeline.outputFileNames)
|
||||
alert(baseOutputAlert += 'Your exports will be imported into AE inside the folder named zz_QC for quality control.');
|
||||
importExportsIntoAE(proj, aeFolders, renderPipeline.outputFolders, renderPipeline.outputFileNames)
|
||||
} else {
|
||||
alert(baseOutputAlert)
|
||||
var outputFolder = new Folder(renderFolderPath);
|
||||
var outputFolder = new Folder.decode(renderFolderPath);
|
||||
outputFolder.execute()
|
||||
}
|
||||
}
|
||||
@@ -433,11 +457,46 @@ function truncateFilePath(filePathString, separator) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// HELPER FUNCTIONS
|
||||
|
||||
/**
|
||||
* @description syncs QC exports settings
|
||||
* @param {any} newVal
|
||||
*/
|
||||
function syncQCExports(newVal){
|
||||
settingsQCCB.value = newVal;
|
||||
qcExports.value = newVal;
|
||||
DEFAULT_SETTINGS.settings.qcExports = newVal;
|
||||
}
|
||||
|
||||
function importExportsIntoAE(proj, folders, location, names){
|
||||
var exports = getExports(location, names);
|
||||
|
||||
/**
|
||||
* @description truncates input file path string for eventual display in UI
|
||||
* @param {string} filePathString
|
||||
* @param {string} separator - OS-specific path separator
|
||||
* @return {string} outputstring for display
|
||||
*/
|
||||
function truncateFilePath(filePathString, separator) {
|
||||
var pathArray = filePathString.split(separator);
|
||||
var startString = pathArray.slice(0, 1).join(separator);
|
||||
var endString = pathArray.slice(-2,pathArray.length).join(separator);
|
||||
|
||||
var outputString = '...' + separator + endString + separator;
|
||||
return outputString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description imports exported files back into AE and sorts into targeted folders
|
||||
* @param {object} proj - app project
|
||||
* @param {array} folders - array of comp folders
|
||||
* @param {string} locations - file path locations of exported files
|
||||
* @param {array} names - output file names
|
||||
*/
|
||||
function importExportsIntoAE(proj, folders, locations, names){
|
||||
var exports = getExports(locations, names);
|
||||
var compFolders = folders.compFolders;
|
||||
for(var e = 0; e<exports.length; e++){
|
||||
var renders = exports[e];
|
||||
@@ -460,6 +519,13 @@ function truncateFilePath(filePathString, separator) {
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* @description creates folders for imported renders to be sorted into
|
||||
* @param {string} parentFolderName
|
||||
* @param {array} exportedComps exported comps from AE
|
||||
* @param {Function} getFolders - callback function to search folders in AE
|
||||
* @return {Object} returns parent folder to import files into and comp folders that are created per rendered comp
|
||||
*/
|
||||
function createImportFolders(parentFolderName, exportedComps, getFolders){
|
||||
var parentFolder = getFolders(app.project,parentFolderName);
|
||||
var compFolders = [];
|
||||
@@ -476,30 +542,48 @@ function truncateFilePath(filePathString, separator) {
|
||||
}
|
||||
|
||||
|
||||
function getExports(location, names){
|
||||
/**
|
||||
* @description gets exported files from output location
|
||||
* @param {array} locations - gets locations of output folders of each exported comp
|
||||
* @param {array} names - output filenames based on output modules
|
||||
* @return {array} absolute file paths of exports
|
||||
*/
|
||||
function getExports(locations, names){
|
||||
var exports = [];
|
||||
var outputFolder = new Folder(location)
|
||||
for(var l = 0; l< locations.length; l++){
|
||||
var location = locations[l];
|
||||
var outputFolder = new Folder(location);
|
||||
var files = outputFolder.getFiles('*.mov');
|
||||
for(var f = 0; f<files.length; f++){
|
||||
var file = files[f];
|
||||
for(var d = 0; d<names.length; d++){
|
||||
var dataName = names[d];
|
||||
if(file.name.replace(/%20/g, ' ') === dataName){
|
||||
exports.push(file.fsName)
|
||||
exports.push(file.absoluteURI)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return exports
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description builds render queue items, output modules, and output files
|
||||
* @param {array} comps - selected comps to be exported
|
||||
* @param {Object} rq - render queue object
|
||||
* @param {array} wallTemplates - output module templates
|
||||
* @param {Object} folderOutput - Selected parent output folder
|
||||
* @return {Object} render queue items, render queue comp references, output file names, output subfolders
|
||||
*/
|
||||
function buildRenderPipeline(comps,rq,wallTemplates,folderOutput){
|
||||
var outputFileNames = [];
|
||||
var rqComps = [];
|
||||
var rqItems = [];
|
||||
var outputFolders = [];
|
||||
for(var c = 0; c<comps.length; c++){
|
||||
var comp = comps[c];
|
||||
var rqComp = rq.items.add(comp);
|
||||
@@ -509,6 +593,7 @@ function truncateFilePath(filePathString, separator) {
|
||||
while(rqCompOMCollect.length < wallTemplates.length){
|
||||
rqCompOMCollect.add()
|
||||
}
|
||||
var folder_path = Folder.decode(folderOutput.absoluteURI);
|
||||
for(var i = 0; i<rqCompOMCollect.length; i++){
|
||||
var om = rqComp.outputModule(i+1);
|
||||
var templateName = wallTemplates[i];
|
||||
@@ -517,7 +602,6 @@ function truncateFilePath(filePathString, separator) {
|
||||
|
||||
|
||||
var file_name = File.decode(om.file.name);
|
||||
var folder_path = Folder.decode(folderOutput);
|
||||
var fileNameSplit = file_name.split('.');
|
||||
var fileNameString = fileNameSplit[0].split('_');
|
||||
var fileNameBaseWall = fileNameString.slice(0,fileNameString.length-1).join('_') + '_'+ templateNameWall.toString() + '_' + fileNameString.slice(-1).toString();
|
||||
@@ -527,36 +611,47 @@ function truncateFilePath(filePathString, separator) {
|
||||
var new_data = {
|
||||
"Output File Info": {
|
||||
"Base Path" : folder_path,
|
||||
"Subfolder Path": rqComp.comp.name,
|
||||
"File Name" : outputFileName
|
||||
}
|
||||
}
|
||||
|
||||
om.setSettings(new_data)
|
||||
}
|
||||
outputFolders.push(folder_path + '/' + rqComp.comp.name);
|
||||
}
|
||||
|
||||
return {
|
||||
rqItems : rqItems,
|
||||
rqComps : rqComps,
|
||||
outputFileNames: outputFileNames
|
||||
outputFileNames: outputFileNames,
|
||||
outputFolders : outputFolders
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description gets targeted OS-specific path separator
|
||||
* @return {string} separator
|
||||
*/
|
||||
function getSeparator(){
|
||||
var os = $.os.toLowerCase().indexOf('mac') >= 0 ? "MAC": "WINDOWS";
|
||||
var separator = os === 'MAC' ? '/' : '\\';
|
||||
return separator
|
||||
}
|
||||
|
||||
/**
|
||||
* @description gets settings folder where settings json lives
|
||||
* @return {Folder} OS-targeted settings folder
|
||||
*/
|
||||
function getSettingsFolder(){
|
||||
var userDataFolder = new Folder(Folder.userData.fsName);
|
||||
var kmToolsFolder = new Folder(userDataFolder.fsName + '/km-tools');
|
||||
var separator = getSeparator();
|
||||
var userDataFolder = new Folder(Folder.userData.absoluteURI);
|
||||
var kmToolsFolder = new Folder(userDataFolder.absoluteURI + '/km-tools');
|
||||
if(!kmToolsFolder.exists){
|
||||
kmToolsFolder.create()
|
||||
}
|
||||
|
||||
var settingsFolder = new Folder(kmToolsFolder.fsName + '/sparks-render-helper');
|
||||
var settingsFolder = new Folder(kmToolsFolder.absoluteURI + '/sparks-render-helper');
|
||||
if(!settingsFolder.exists){
|
||||
settingsFolder.create()
|
||||
}
|
||||
@@ -564,11 +659,19 @@ function truncateFilePath(filePathString, separator) {
|
||||
return settingsFolder
|
||||
}
|
||||
|
||||
/**
|
||||
* @description gets settings file
|
||||
* @return {File} settings json file
|
||||
*/
|
||||
function getSettingsFile(){
|
||||
var settingsFile = new File(getSettingsFolder().fsName + '/settings.json')
|
||||
var settingsFile = new File(getSettingsFolder().absoluteURI + '/settings.json')
|
||||
return settingsFile
|
||||
}
|
||||
|
||||
/**
|
||||
* @description reads settings json file
|
||||
* @return {Object} json data from settings file
|
||||
*/
|
||||
function readSettingsFile(){
|
||||
var file = getSettingsFile();
|
||||
if(!file.exists){
|
||||
@@ -591,13 +694,18 @@ function truncateFilePath(filePathString, separator) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description writes data to settings file
|
||||
* @param {Object} data - data to be written to json file
|
||||
* @return {boolean}
|
||||
*/
|
||||
function writeSettingsFile(data){
|
||||
var file = getSettingsFile();
|
||||
|
||||
var json = JSON.stringify(data, null, 4);
|
||||
|
||||
if(!file.open('w')){
|
||||
alert('Could not open settings file:\n' + file.fsName)
|
||||
alert('Could not open settings file:\n' + file.absoluteURI)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -611,6 +719,12 @@ function truncateFilePath(filePathString, separator) {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @description builds help message for help tab
|
||||
* @param {string} scriptName
|
||||
* @param {srting} versionNumber
|
||||
* @return {string}
|
||||
*/
|
||||
function setHelpMessage(scriptName, versionNumber){
|
||||
var lines = [
|
||||
'ABOUT ' + scriptName.toUpperCase(),
|
||||
|
||||
Reference in New Issue
Block a user