-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISO_MoveTimeIndicatorTimecode.jsx
More file actions
121 lines (92 loc) · 3.22 KB
/
Copy pathISO_MoveTimeIndicatorTimecode.jsx
File metadata and controls
121 lines (92 loc) · 3.22 KB
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
// ISO_MoveTimeIndicatorTimecode.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by ChatGPT-5.5
// Date: June 11, 2026
// Description: This After Effects script will open the selected comps in the Project window and move the Current Time Indicator to a user-specified timecode (H:MM:SS:FF).
(function () {
app.beginUndoGroup("Move CTI to Timecode");
try {
var userInput = prompt(
"Enter the target timecode (H:MM:SS:FF):",
"0:00:00:00"
);
if (userInput === null) {
alert("Operation cancelled.");
return;
}
userInput = userInput.replace(/^\s+|\s+$/g, "");
// Accept:
// 1:02:03:12
// 01:02:03:12
var timecodeRegex = /^\d{1,2}:\d{2}:\d{2}:\d{2}$/;
if (!timecodeRegex.test(userInput)) {
alert(
"Invalid timecode format.\n\n" +
"Please use:\n" +
"H:MM:SS:FF\n\n" +
"Examples:\n" +
"1:02:03:12\n" +
"01:02:03:12"
);
return;
}
var parts = userInput.split(":");
var hours = parseInt(parts[0], 10);
var minutes = parseInt(parts[1], 10);
var seconds = parseInt(parts[2], 10);
var frames = parseInt(parts[3], 10);
if (minutes > 59 || seconds > 59) {
alert(
"Invalid timecode.\n\n" +
"Minutes and seconds must be between 00 and 59."
);
return;
}
var selectedItems = app.project.selection;
if (selectedItems.length === 0) {
alert("Please select at least one composition in the Project panel.");
return;
}
var processedCount = 0;
var skippedCount = 0;
for (var i = 0; i < selectedItems.length; i++) {
var item = selectedItems[i];
if (item !== null && item instanceof CompItem) {
var frameRate = item.frameRate;
if (frames >= frameRate) {
alert(
"Invalid frame value for composition:\n\n" +
item.name + "\n\n" +
"Entered frame number: " + frames + "\n" +
"Composition frame rate: " + frameRate + " fps\n\n" +
"Frame value must be less than the composition frame rate."
);
return;
}
var targetTime =
(hours * 3600) +
(minutes * 60) +
seconds +
(frames / frameRate);
item.openInViewer();
item.time = targetTime;
processedCount++;
} else {
skippedCount++;
}
}
alert(
"CTI moved successfully.\n\n" +
"Timecode: " + userInput + "\n" +
"Compositions affected: " + processedCount + "\n" +
"Items skipped: " + skippedCount
);
} catch (err) {
alert(
"An error occurred:\n\n" +
err.toString()
);
} finally {
app.endUndoGroup();
}
}());