How to get image name in text field

I have a test that i need to do.
Basically i need the image name “1.png” excluding the extension to put in a text box below and clicked on button.

Steps:
Get image name from path (4)
Fill text field with the names (4)
Click button
Repeat

Here is the html code to pull the data from.

    
 
 
 
 
 



I need to be able run the script in console?