Can I extract a formatted string from a PDF File name in JavaScript?

Viewed 222

I have seen some questions regarding extracting information from a PDF file using JS.

I am wondering if there would be anyway to build a program where I can drag upload a file ( or group of files ) into a GUI and then convert the PDF file names into a table of strings... but formatted.

I have a bunch of PDF formatted like

“First.Last.Date”

My job requires me to go through a long list of PDF files, manually read the names within, and then search for them in a database, and if I could do this in a JavaScript program then my workflow time would be cut in half ( if not more ).

Sorry if this question lacks any code. I am not sure if this is worth perusing in JavaScript and not sure where to start with file uploads.

1 Answers

I'm not exactly clear on what you want to do with the file names once you've got them, but the following code will get you the file names.

document.getElementById('myfiles').onchange = function (e) {
  var fileList = [];
  for (var i = 0; i < e.target.files.length; i++) {
    fileList.push(e.target.files[i].name);
  }
  console.log(fileList);
};
<label for="myfile">Select PDF file(s):</label>
<input type="file" id="myfiles" name="myfiles" multiple>

Related