Clip rename multiple files from clipboard list
Dear soundflower,
I often have to deliver my rerec files in a special name convention. Rather
So i have put some lines together to make the renaming task of these files a little easier.
In this example I have 6 tracks
PM
ME
DX
MX
FX
OPT
which I want to rename to
PROJECTTITLE_25fps_PM_2p0_220219
PROJECTTITLE_25fps_ME_2p0_220219
PROJECTTITLE_25fps_DX_2p0_220219
PROJECTTITLE_25fps_MX_2p0_220219
PROJECTTITLE_25fps_FX_2p0_220219
PROJECTTITLE_25fps_OPT_2p0_220219
Instead of naming each file individually I select the number of clips in ProTools that I want to rename and then grab the filenames from the clipboard and let the script do the renaming.
Here is how it works:
https://www.dropbox.com/s/rz43xz172ivlujv/ClipRenameFromClipboard.mp4?dl=0
// A script to rename many rerec files from the clipboard
// v 1.0.0
if (!sf.ui.proTools.isRunning) throw `Pro Tools is not running`;
// Get all the track names from clipboard.
// This should correspond to the track count of the selected tracks that we want to rename
let trackNamesFromClipboard = sf.clipboard.getText().text.split('\n').map(line => line.trim()).filter(line => line !== '');
//var selectedTrackNames = sf.ui.proTools.selectedTrackNames;
//log(sf.ui.proTools.selectedTrackCount + ' selected tracks');
function renameClip(index) {
// Make sure we have no search in Clips list - if we had, Clip Rename won't work (Pro Tools bug)
sf.keyboard.press({ keys: 'cmd+shift+d' });
// Open menu Clip => Rename...
sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
// Wait for 'Name' dialog to come up, assign the dialog to dlg variable
var dlg = sf.ui.proTools.windows.whoseTitle.is('Name').first.elementWaitFor({}, 'Could not find "Name" dialog').element;
// Find the first text field
var textField = dlg.groups.whoseTitle.is('Name').first.textFields.first;
// Set the value of the textField
textField.elementSetTextFieldWithAreaValue({ value: trackNamesFromClipboard[index] });
// Click OK
dlg.buttons.whoseTitle.is('OK').first.elementClick();
// Wait for the dialog to close
dlg.elementWaitFor({waitType:"Disappear"});
}
let selectedTracks = sf.ui.proTools.selectedTrackHeaders;
function main() {
// Make sure Pro Tools main window is active
sf.ui.proTools.appActivateMainWindow();
// Loop through Monday - Sunday from the days of the week array.
for (let i = 0; i < trackNamesFromClipboard.length; i++) {
// Move to next Clip
//log(selectedTracks[i]);
selectedTracks[i].trackSelect();
// Function for renaming the clip
renameClip([i]);
}
sf.ui.proTools.trackDeselectAll();
//selectedTracks[0].trackSelect();
}
main();
Best Stefan