bulk upload to Drupal


I'm close to having a script to bulk upload a set of h5p. files to drupal.
The last hurdle is that, if you click "upload a file", a filepicker is opening that is waiting for the selection of a file.
This prevents me of looping trough all the content of a directory and uploading all files inside of that directory with one click.

So, i need to know the location of the filepicker and how the return of this function is formatted.
I will try to prevent the filepicker from starting and set the value of the filepath from my script.
This will enable me to start the script and looping trough the files of the selected directory so I can upload my library by simply starting the script and waiting untill all files are in.

If someone can point me in the right direction it would be really aprreciated.

What I already have is:
Starting the script,
All interactions are automated until you need to pick a file and continue the script.
(add content, select book page, choose upload, select upload file)
Manual selection of file and click continue 

All further actions are also automated.
(set select choose, select use, fill edit-title-0-value whit filename, select save)

So 2 clicks for each h5p. Seems Ok but I have over 1600 :-(