I'm a complete JavaScript rookie...actually complete rookie with programming in general, so please bare with me.
Basically I have a Premiere Pro script that takes a CSV file and converts its data into clip markers, and that part works fine and everything.
The issue I'm currently dealing with:
Instead of just having to manually select a CSV file using File.openDialog() every time I want to generate markers, I thought I'd just hardcode the file path(always the same path so it made sense) + grab the clip name (both the CSV files and clips have a date timestamp as their names) and just grab the CSV from the path with the matching clip name.
var clip = // "insert clip name here.mp4", example: 2021-09-21 00-50-27.mp4
var clipname = clip.name.replace(".mp4", '.csv'); //my janky way of dealing with the extensions lol
var userCsv = File (('/d/TIMESTAMPS/CSV/') + escape(clipname));
//userCSV example: "[File] /d/TIMESTAMPS/CSV/2021-09-21%2000-50-27.csv"
parseCsvData(userCsv);
Now, this works fine, except when the CSV's name timestamp is a few seconds behind, so the CSV file can no longer be matched to the clip name.
Example:
clip name: 2021-09-21 00-50-27.mp4
CSV name: 2021-09-21 00-50-29.csv¨
So now I'm trying to figure out a way to match the CSV to the clip even if the seconds in the timestamp/name are off, let's say give it a range of 10 seconds of difference and still be able to get a match.
Now I'm thinking of 2 possible ways to deal with this.
File.openDialog() as a fallback in that case I guess.I'm using Adobe ExtendScript Toolkit if that matters in any way.
Any idea on how to solve this? Thank you!