-
Notifications
You must be signed in to change notification settings - Fork 2
/
setOutputPaths.jsx
186 lines (173 loc) · 6.29 KB
/
setOutputPaths.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Copyright (c) 2012
// Fabian "fabiantheblind" Morón Zirfas
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to
// whom the Software is furnished to do so, subject to
// the following conditions:
// The above copyright notice and this permission notice
// shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIO
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// see also http://www.opensource.org/licenses/mit-license.php
{
//@include "Debugger.jsx";
var deeBug = new Debugger(
true,
"setOutputPath.jsx version 0.1",
"This is a debug version"
);
deeBug.write_head();
run_script_set_output_path(this);
function run_script_set_output_path(thisObj) {
if (check_security_settings() == false) {
alert(
"This script requires the scripting security preference to be set.\n" +
'Go to the "General" panel of your application preferences,\n' +
'and make sure that "Allow Scripts to Write Files and Access Network" is checked.'
);
return;
}
// this is global
var SOP_meta = new Object();
SOP_meta.undoName = "Change Render Locations";
SOP_meta.ddlStrings = [
"[projectName]",
"[compName]",
"[fileExtension]",
"[#####]",
"[renderSettingsName]",
"[outputModuleName]",
"[frameRate]",
"[startFrame]",
"[endFrame]",
"[durationFrames]",
"[startTimecode]",
"[endTimecode]",
"[durationTimecode]",
"[channels]",
"[projectColorDepth]",
"[outputColorDepth]",
"[compressor]",
"[fieldOrder]",
"[pulldownPhase]",
"[width]",
"[height]"
];
SOP_meta.outname = "[compName]_[#####].[fileExtension]";
/// THIS WILL CHECK IF PANEL IS DOCKABLE OR FLAOTING WINDOW
var win = buildUI(thisObj);
if (win != null && win instanceof Window) {
win.center();
win.show();
} // end if win null and not a instance of window
function buildUI(thisObj) {
var win =
thisObj instanceof Panel
? thisObj
: new Window("palette", "Set Output Path", [0, 0, 150, 260], {
resizeable: true
});
if (win != null) {
var H = 25; // the height
var W1 = 50; // the width
var G = 5; // the gutter
var x = G;
var y = G;
win.setpath_button = win.add(
"button",
[x, y, x + W1 * 5, y + H],
"Set Output Path"
);
y += H + G;
win.add_to_name_dropdl = win.add(
"dropdownlist",
[x, y, x + W1 * 5, y + H],
SOP_meta.ddlStrings
);
y += H + G;
win.outname_etxt = win.add(
"edittext",
[x, y, x + W1 * 5, y + H * 4],
SOP_meta.outname,
{ multiline: true }
);
win.add_to_name_dropdl.onChange = function() {
win.outname_etxt.textselection = this.selection.text;
SOP_meta.outname = win.outname_etxt.text;
};
win.outname_etxt.onChange = function() {
SOP_meta.outname = this.text;
};
win.setpath_button.onClick = function() {
changeRenderLocations();
}; // end of setpath_button on click
//
}
return win;
} // close buildUI
function changeRenderLocations() {
var newLocation = Folder.selectDialog("Select a render output folder...");
if (newLocation != null) {
app.beginUndoGroup(SOP_meta.undoName);
// Process all render queue items whose status is set to Queued.
for (var i = 1; i <= app.project.renderQueue.numItems; ++i) {
var curItem = app.project.renderQueue.item(i);
if (curItem.status == RQItemStatus.QUEUED) {
// Change all output modules for the current render queue item.
for (j = 1; j <= curItem.numOutputModules; ++j) {
var curOM = curItem.outputModule(j);
// this is the addition by fabiantheblind
if (curItem.numOutputModules > 1) {
var targetFolder = new Folder(
newLocation.fsName + "/" + curItem.comp.name + "_" + j
);
} else {
var targetFolder = new Folder(
newLocation.fsName + "/" + curItem.comp.name
);
}
if (!targetFolder.exists) {
targetFolder.create();
}
var tF = targetFolder.fsName;
// now there is a folder for each output module
// from here on
var oldLocation = curOM.file;
curOM.file = new File(tF + "/" + SOP_meta.outname);
deeBug.addLineToInfo("RQ Item: " + i + " OModule: " + j);
deeBug.addLineToInfo("---- Old location: " + oldLocation.fsName);
deeBug.addLineToInfo("---- New Location: " + curOM.file.fsName);
// alert("New output path:\n"+curOM.file.fsName, SOP_meta.undoname);
}
}
}
// alert("done");
deeBug.write_infos();
app.endUndoGroup();
}
}
function check_security_settings() {
var safeToRunScript = false;
// Check if we are allowed to access the network.
var securitySetting = app.preferences.getPrefAsLong(
"Main Pref Section",
"Pref_SCRIPTING_FILE_NETWORK_SECURITY"
);
if (securitySetting != 1) {
safeToRunScript = false;
} else {
safeToRunScript = true;
}
return safeToRunScript;
} // end check_security_settings
} // end of run_script_set_output_path enclose all
}