Title
Save Session as New Version - PT Script
What do you expect to happen when you run the script/macro?
Save Pro Tools session as a new version with incremental version number
Are you seeing an error?
27.12.2023 09:11:54.61 [Backend]: Logging error in action (01) ClickButtonAction: ClickButtonAction requires UIElement
27.12.2023 09:11:54.62 [Backend]: Logging error in action (01) ClickButtonAction: ClickButtonAction requires UIElement
!! Command Error: Save Session as New Version [user:ckcpn8j7y001hjt10br55i3y1:ck1we9pyd0002a610v5utbw5l]:
ClickButtonAction requires UIElement (Save Session as New Version: Line 16)
What happens when you run this script?
It just gives an error and doesnt complete.
It worked on previous version of Pro Tools but newer updates have changed the PT menu items.
I tried to tweak the script to match the new menu items but it's still not working
How were you running this script?
I used a keyboard shortcut within the target app
How important is this issue to you?
4
Details
{ "inputExpected": "Save Pro Tools session as a new version with incremental version number", "inputIsError": true, "inputError": "27.12.2023 09:11:54.61 [Backend]: Logging error in action (01) ClickButtonAction: ClickButtonAction requires UIElement\n\n27.12.2023 09:11:54.62 [Backend]: Logging error in action (01) ClickButtonAction: ClickButtonAction requires UIElement\n!! Command Error: Save Session as New Version [user:ckcpn8j7y001hjt10br55i3y1:ck1we9pyd0002a610v5utbw5l]:\nClickButtonAction requires UIElement (Save Session as New Version: Line 16)", "inputWhatHappens": "It just gives an error and doesnt complete. \n\nIt worked on previous version of Pro Tools but newer updates have changed the PT menu items. \n\nI tried to tweak the script to match the new menu items but it's still not working", "inputHowRun": { "key": "-Mpfwh4RkPLb2LPwjePT", "title": "I used a keyboard shortcut within the target app" }, "inputImportance": 4, "inputTitle": "Save Session as New Version - PT Script" }
Source
//First save the current version
sf.ui.proTools.getMenuItem('File', 'Save Session').elementClick({}, function () { }); //can be disabled
//Get our filename without extension
var fileNameWithoutExtension = sf.ui.proTools.mainWindow.invalidate().sessionPath.split('/').slice(-1)[0].split('.').slice(0, -1).join('.');
//Create a new name (get the name and suffixed number - if your session name was 'My Session 42' then save 'My Session ' in grps[1] and '42' in grps[2])
var grps = fileNameWithoutExtension.match(/^(.+?)(\d+)$/);
//Construct a new name based on the prefix and the number (+1), followed by the '.ptx' suffix. If there was no number, just add ' 2'
var newNumber = !grps || grps.length === 0 || isNaN(Number(grps[2])) ? '_2' : ((Number(grps[2]) + 1) + '');
var newName = (grps ? grps[1] : (fileNameWithoutExtension)) + newNumber + '.ptx';
//Invoke File Save As.
sf.ui.proTools.getMenuItem('File', 'Save Session As...').elementClick();
//Wait for the Save dialog to appear
var dlg = sf.ui.proTools.windows.invalidate().whoseTitle.is('Save').waitFor().element;
//Enter the new name
dlg.textFields.first.value.value = newName;
//Click Save
dlg.buttons.whoseTitle.is('Save').first.elementClick();
Links
User UID: YomoducekrYeZ1fxPzsZ9d4VmZN2
Feedback Key: sffeedback:YomoducekrYeZ1fxPzsZ9d4VmZN2:-NmfpqaGG2W_P64j0THH
Feedback ZIP: Qj/+QEhOHoNEFxBJrEOXE77b3auBfGVIJbGYYHc13+necghK008JhbBn6+15dMUnLkoFYuMQuvYceOaLBO7Mcr1rZAh4/jTsPzCJ0fHd4U97ndsRHmtt7fMH+Fe2CGhV6yFJgMT8MDpzqNKo0rRd97wnfp1rUaR0XtGl4ah76uYyAAL0Mz5hoAlvY5KRnYx4lh5FoPiRt/0YwTd3a9pTx5Yr94pKBNYc9AMu1tskDS80nIS3aZvRxOvKvME/SqRoghB3naS8Vvq0tyWHB/d77jNCrJiP0DauoMqi4mQBYWRWDsHrNM3ze6AfKFJbvbFlPSpjJU2tVd0G17HhH+5MpSq16nJAxMhtt8qYSbVz0K0=
- Raphael Sepulveda @raphaelsepulveda2023-12-28 17:07:39.509Z
@Brandon_Metcalf, haven't tested it but I'm pretty sure the error is happening due on the use of an ellipsis character ("…") instead of three periods ("...") in
"Save Session As...
on line 16.I recently helped another user with this, you can read more about it here.
In your case, replacing line 16 with the one below should do the trick:
sf.ui.proTools.getMenuItem('File', 'Save Session As…').elementClick();
Brandon Metcalf @Brandon_Metcalf
back up and running! thanks so much for your help