Export Timecode as CSV
Title
Export Timecode as CSV
What do you expect to happen when you run the script/macro?
This macro is supossed to export markers as text to my bounces folder within the perspective session folder, then change to .txt to .csv.
Are you seeing an error?
I have everthing up to the session folder navigation.
What happens when you run this script?
Ive tried, UI select folder or whatever it is, doesnt work.
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
5
Details
{ "inputExpected": "This macro is supossed to export markers as text to my bounces folder within the perspective session folder, then change to .txt to .csv.\n", "inputIsError": true, "inputError": "I have everthing up to the session folder navigation. ", "inputWhatHappens": "Ive tried, UI select folder or whatever it is, doesnt work. \n", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 5, "inputTitle": "Export Timecode as CSV\n" }
Source
//Macro converted to script
sf.ui.proTools.menuClick({
menuPath: ["File","Export","Session Info as Text..."],
});
sf.ui.proTools.windows.whoseTitle.is("Export Session Text").first.checkBoxes.whoseTitle.is("Include File List").first.mouseClickElement();
sf.ui.proTools.windows.whoseTitle.is("Export Session Text").first.checkBoxes.whoseTitle.is("Include Clip List").first.mouseClickElement();
sf.ui.proTools.windows.whoseTitle.is("Export Session Text").first.checkBoxes.whoseTitle.is("Include Plug-In List").first.mouseClickElement();
sf.ui.proTools.windows.whoseTitle.is("Export Session Text").first.checkBoxes.whoseTitle.is("Include Track EDL's").first.mouseClickElement();
sf.keyboard.press({
keys: "return",
});
sf.wait();
sf.keyboard.type({
text: "Markers",
});
sf.keyboard.press({
keys: "cmd+up",
});
Links
User UID: zNchbgqMvBUNXIhmLZsA7wqfiDl1
Feedback Key: sffeedback:zNchbgqMvBUNXIhmLZsA7wqfiDl1:-Ndf7azIAbGGKxJX1d64
Linked from:
- Chad Wahlbrink @Chad2023-09-07 15:23:42.100Z
Hey @Lynn_Graber!
Give this script a shot, and let me know if it does what you'd like to accomplish. Note that I'm using commands from the Pro Tools SDK Scripting Library for this to avoid using the "Export Session Text" menu entirely.
// Use Pro Tools SDK to Fetch 'Markers' Info as Text let sessionInfo = sf.app.proTools.getSessionInfoAsText({includeMarkers: true, includeClipList:false, includePluginList:false, includeTrackEdls: false, includeFileList:false, trackOffsetOptions:`TimeCode` }, `Couldn't Get Session Info`).sessionInfo // Use Pro Tools SDK Fetch session path let sessionName = sf.app.proTools.getSessionPath().sessionPath.slice(1).replace(/\:/g, '/'); // Get Session Folder from Session Path let sessionPathSplit = sessionName.split('/'); sessionPathSplit.pop(); let sessionFolder = sessionPathSplit.join('/') + '/'; // Format the Session Info Text as CSV let markerCSV = sessionInfo.split('\n').slice(1,-1).map(l => l.replace(/[^a-zA-Z0-9|:\-\. #]+/g, ',')).join('\n'); // Write the CSV File to Bounce Files Folder sf.file.writeText({path:sessionFolder + `/Bounced Files/Markers.csv`, text: markerCSV }, `Could Not Write Text`); // Select the CSV in Finder sf.appleScript.finder.select(sessionFolder + `/Bounced Files/Markers.csv`);
- LLynn Graber @Lynn_Graber
This works great. I just need to find a way to clean everything up and only leave the time code and marker names. :)
Chad Wahlbrink @Chad2023-09-07 15:38:57.274Z
Ah, great! So you specifically want just a two-column CSV with timecode and marker name?
- LIn reply toLynn_Graber⬆:Lynn Graber @Lynn_Graber
This is what I am shooting for the final csv to look like.
Chad Wahlbrink @Chad2023-09-07 16:15:20.514Z
This should do it @Lynn_Graber. Let me know if this helps:
// Use Pro Tools SDK to Fetch 'Markers' Info as Text let sessionInfo = sf.app.proTools.getSessionInfoAsText({ includeMarkers: true, includeClipList: false, includePluginList: false, includeTrackEdls: false, includeFileList: false, trackOffsetOptions: `TimeCode` }, `Couldn't Get Session Info`).sessionInfo // Use Pro Tools SDK Fetch session path let sessionName = sf.app.proTools.getSessionPath().sessionPath.slice(1).replace(/\:/g, '/'); // Get Session Folder from Session Path let sessionPathSplit = sessionName.split('/'); sessionPathSplit.pop(); let sessionFolder = sessionPathSplit.join('/') + '/'; // Format the Session Info Text as CSV, only capturing Markers let markerCSV = sessionInfo.split('M A R K E R S L I S T I N G')[1].split('\n').slice(2, -1).map(l => l.replace(/[^a-zA-Z0-9|:\-\. #]+/g, ',')) // Split each row apart, filter rows for location and marker name .map(l => l.split(',').filter((l, i) => { if(i === 1 || i === 4){ return l } }).join(",")).join('\n'); // Write the CSV File to Bounce Files Folder sf.file.writeText({path:sessionFolder + `/Bounced Files/Markers.csv`, text: markerCSV }, `Could Not Write Text`); // Select the CSV in Finder sf.appleScript.finder.select(sessionFolder + `/Bounced Files/Markers.csv`); sf.ui.finder.appActivate();
- LLynn Graber @Lynn_Graber
Holy crap. Thanks man. This is awesome.
- LLynn Graber @Lynn_Graber
Man, can I ask one last thing? How can I filter markers? Like, if I dont want the START (always marker 1) and END (always marker 99) to be in the final document.
Chad Wahlbrink @Chad2023-09-07 17:23:03.459Z
Hey @Lynn_Graber.
This will filter out any Markers named in the array in Line 2:
// Template let markersToIgnore = ['START', 'END'] //////////////////////////////////////////////////////// // Use Pro Tools SDK to Fetch 'Markers' Info as Text let sessionInfo = sf.app.proTools.getSessionInfoAsText({ includeMarkers: true, includeClipList: false, includePluginList: false, includeTrackEdls: false, includeFileList: false, trackOffsetOptions: `TimeCode` }, `Couldn't Get Session Info`).sessionInfo // Use Pro Tools SDK Fetch session path let sessionName = sf.app.proTools.getSessionPath().sessionPath.slice(1).replace(/\:/g, '/'); // Get Session Folder from Session Path let sessionPathSplit = sessionName.split('/'); sessionPathSplit.pop(); let sessionFolder = sessionPathSplit.join('/') + '/'; // Format the Session Info Text as CSV, only capturing Markers let markerCSV = sessionInfo.split('M A R K E R S L I S T I N G')[1].split('\n').slice(2, -1).map(l => l.replace(/[^a-zA-Z0-9|:\-\. #]+/g, ',')) // Split each row apart, filter rows for location and marker name .map(l => l.split(',').filter((l, i) => { if (i === 1 || i === 4) { return l.replace(/\s+$/g, '') } }).join(",")) // Replace trailing white space from columns .map(reg => reg.replace(/\s+$/g, '')).map(reg => reg.replace(/\s\s/g, '')) // Filter out Rows from our markersToIgnore .filter(l => { if (!markersToIgnore.includes(l.split(',')[1])){ return l } }).join('\n'); // Write the CSV File to Bounce Files Folder sf.file.writeText({path:sessionFolder + `/Bounced Files/Markers.csv`, text: markerCSV }, `Could Not Write Text`); // Select the CSV in Finder sf.appleScript.finder.select(sessionFolder + `/Bounced Files/Markers.csv`); sf.ui.finder.appActivate();
Chad Wahlbrink @Chad2023-09-07 17:24:04.106Z
You could add other markers to filter, by naming them in line 2.
for example:let markersToIgnore = ['START', 'Chorus', 'Verse', 'END']
- LIn reply toLynn_Graber⬆:Lynn Graber @Lynn_Graber
Hey Chad, I am trying to do one last thing with this script and I am not sure what part to edit. I need to include LOCATION and NAME above my markers. I have tried a few things but I am not sure what line is filtering that out.
- LLynn Graber @Lynn_Graber
- LIn reply toLynn_Graber⬆:Lynn Graber @Lynn_Graber
OMG. I got it.
Line 17, changed .slice(2, _1) to .slice(1, _1)
Yay.
- RIn reply toLynn_Graber⬆:Registered KOUZ @Registered_KOUZ
Hello @Chad
Do you know if the reverse script is feasible?
Namely, to be able to create markers in a ProTools session from a .csv similar to Lynn's, timecodes and marker names.
Thank you mate.