Using Chrome Console to download file (rename files and get objects)

I am trying to use Chrome console to download a series of files in a faster way using a for loop. It is a public resource, but its website is old and does not support multiple files download at the same time and there are hundreds of them…

The thing is, when downloading the file, Chrome seems to assign a random name to the file – how can I rename the file that I am going to download in the console?

Also, I used getElementByTagName to get the button inside the page, however I cannot get the .click() or .submit() work. Are there any method to trigger a click on the button?

24 thoughts on “Using Chrome Console to download file (rename files and get objects)”

  1. If you are downloading a file for which you are using a link <a> then set the “download” attribute. It will be used as default download name

  2. if you want to download the file u can use from below

    (function(console) { = function(data, filename){
            if(!data) {
                console.error(' No data')
            if(!filename) filename = 'console.html'
            if(typeof data === "object"){
                data = JSON.stringify(data, undefined, 4)
            var blob = new Blob([data], {type: 'text/json'}),
                e    = document.createEvent('MouseEvents'),
                a    = document.createElement('a')
   = filename
            a.href = window.URL.createObjectURL(blob)
            a.dataset.downloadurl =  ['text/json',, a.href].join(':')
            e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)

    just use


Leave a Comment