-
Notifications
You must be signed in to change notification settings - Fork 22
/
Replace Items With Placeholders.jsx
47 lines (41 loc) · 1.07 KB
/
Replace Items With Placeholders.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
/**
* Replaces all eligible selected items with placeholders
*
* @author Zack Lovatt <[email protected]>
* @version 0.1.1
*/
(function replaceItemsWithPlaceholders() {
var items = app.project.selection;
app.beginUndoGroup("Replace Items With Placeholders");
try {
for (var ii = 0, il = items.length; ii < il; ii++) {
var item = items[ii];
if (!(item instanceof FootageItem)) {
continue;
}
var oldName = item.name;
item.replaceWithPlaceholder(
ii.toString(),
clamp(item.width, 4, 30000),
clamp(item.height, 4, 30000),
clamp(item.frameRate, 1, 99),
clamp(item.duration, 0, 10800)
);
item.name = oldName;
}
} catch (e) {
alert(e, "Replace Items With Placeholders");
} finally {
app.endUndoGroup();
}
/**
* Clamps a value between min and max
*
* @param {number} value Number to clamp
* @param {number} min Min value
* @param {number} max Max value
*/
function clamp(value, min, max) {
return Math.max(Math.min(value, max), min);
}
})();