Batch Rename - remove .cm
Hi All,
I'm trying to create a script that will batch rename selected clips with a specifc set of paramaters. I would like to remove ".cm" after committing a file. I've got a preset saved in Batch Rename that Finds ".cm" and replaces it with nothing. This works just fine but I can't quite figure out the code I'm missing to complete the operation. I can get to the window but thats as far as I can get it. Current code thus far:
sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is('Clip List').first.popupMenuSelect({
menuPath: ["Batch Rename..."],
});
sf.ui.proTools.windows.whoseTitle.is('Batch Clip Rename').first.elementWaitFor();
sf.ui.proTools.windows.whoseTitle.is('Batch Clip Rename').first.textFields.whoseTitle.is('').allItems[6].elementClick();
Thanks so much!
- samuel henriques @samuel_henriques
Hello Scott Smith,
try this:
/** * @param {string} find * @param {string} replace */ function batchTrackRenameWinOptions(find, replace) { sf.keyboard.press({ keys: "alt+shift+r", fast: true }); const batchTrackRenameWin = sf.ui.proTools.windows.whoseTitle.is('Batch Track Rename').first.elementWaitFor({}).element; const checkBoxWhoseTitle = batchTrackRenameWin.checkBoxes.whoseTitle checkBoxWhoseTitle.is('Replace').first.checkboxSet({ targetValue: "Enable" }); checkBoxWhoseTitle.is('Clear Existing Name').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Regular Expressions').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Trim').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Add').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Numbering').first.checkboxSet({ targetValue: "Disable" }); // Find batchTrackRenameWin.textFields.whoseTitle.is('').first.elementSetTextFieldWithAreaValue({ value: find }); // Replace batchTrackRenameWin.textFields.whoseTitle.is('').allItems[1].elementSetTextFieldWithAreaValue({ value: replace }); batchTrackRenameWin.buttons.whoseTitle.is('OK').first.elementClick(); batchTrackRenameWin.elementWaitFor({ waitType: "Disappear" }); } sf.ui.proTools.appActivateMainWindow() sf.ui.proTools.invalidate() batchTrackRenameWinOptions(".cm", "")
- SScott Smith @Scott_Smith
Thanks Samuel
Im getting the following error, sureley its something I'm doing wrong:"Could not open popup menu (.cm rename: Line 1)
popupMenu.open.fromElement requires an element"The script I'm currently using is the one I originally sent with yours added on. This may be incorrect. If I use only what you sent I get a different error:
"Element was not found or removed after waiting 2000 ms (.cm rename: Line 9)"
Thanks so much for your help!
samuel henriques @samuel_henriques
The one I sent should do it all.
Could you send me a screen recording so I can see it please?
- SScott Smith @Scott_Smith
Here you go! Couldnt work out how to send an actual video. Thanks!
samuel henriques @samuel_henriques
you can send a dropbox link with the video
- SScott Smith @Scott_Smith
Here you go!
samuel henriques @samuel_henriques
I'm sorry, it fails because you are running outside protools. Try with a shortcut trigger.
I'll write a bit to activate pro tools first, just a moment.samuel henriques @samuel_henriques
Just updated with a line to activate pro tools. This way it will work if you run it with any other application active.
- SScott Smith @Scott_Smith
Thanks Samuel,
When I have PT open and trigger it from the stream deck it works. Only issue is this is batch track rename. I'm looking for Batch Clip Rename ;)Thanks for all your help!
samuel henriques @samuel_henriques
ahhhhh. okok just a moment
samuel henriques @samuel_henriques
Here you go.
I changed the find/replace to a regular expression so it will only find the match from the end of the name. ( Very unlikely you would have .cm in the middle of a clip name but...)
Hope this is it
/** * @param {string} find * @param {string} replace */ function batchClipRenameWinOptions(find, replace) { sf.ui.proTools.menuClick({ menuPath: ["View", "Other Displays", "Clip List"], targetValue: "Enable" }) sf.ui.proTools.mainWindow.popupButtons.whoseTitle.is("Clip List").first.popupMenuSelect({ menuPath: ["Batch Rename..."], }); const batchClipRenameWin = sf.ui.proTools.windows.whoseTitle.is('Batch Clip Rename').first.elementWaitFor({}, 'Bach Rename Window failed to open \nCheck clip selection.').element; const checkBoxWhoseTitle = batchClipRenameWin.checkBoxes.whoseTitle checkBoxWhoseTitle.is('Replace').first.checkboxSet({ targetValue: "Enable" }); checkBoxWhoseTitle.is('Clear Existing Name').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Regular Expressions').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Trim').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Add').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is('Numbering').first.checkboxSet({ targetValue: "Disable" }); checkBoxWhoseTitle.is("Regular Expressions").first.checkboxSet({ targetValue: "Enable" }); // Find batchClipRenameWin.textFields.whoseTitle.is('').first.elementSetTextFieldWithAreaValue({ value: find }); // Replace batchClipRenameWin.textFields.whoseTitle.is('').allItems[1].elementSetTextFieldWithAreaValue({ value: replace }); batchClipRenameWin.buttons.whoseTitle.is('OK').first.elementClick(); batchClipRenameWin.elementWaitFor({ waitType: "Disappear" }); } sf.ui.proTools.appActivateMainWindow() sf.ui.proTools.invalidate() // $ will match .cm from end of name batchClipRenameWinOptions(".cm$", "")
- SScott Smith @Scott_Smith
This works perfectly. Thank you so much Samuel for taking the time. Much appreciated, you've just saved me a ton of time. Happy Holidays and all the best for the New Year
samuel henriques @samuel_henriques
Awesome. Happy holidays to you too!!