How can I download a file from a URL with a varying file extension on windows with native scripting?

0

I want to download a file from a specific url, the file will change extension, but not name, and I want the same download command to be able to download the file no matter what the file extension is.

I have tried wget in powershell, ex:

wget example.com/test/file

This gets the file, but only doesn't download it to a file. I can use this:

wget example.com/test/file -OutFile file

But this doesn't add the file extension.

Any help would be greatly appreciated.

INTENSEFIRE

Posted 2018-08-31T06:30:40.777

Reputation: 135

1Is the file extension one of a set of known extensions? Does the web server have directory browsing enabled so you can see the latest filename? – HelpingHand – 2018-09-01T00:29:56.493

Directory browsing is enabled, and it would be ideal to have it work with any extension, but .exe, .bat, and .png are the set that I would like to at least have. – INTENSEFIRE – 2018-09-01T03:58:54.090

Well you could use this approach: https://pastebin.com/feRb67eD it tries each of the array of extensions in turn, so you could add to that list.

– HelpingHand – 2018-09-01T09:37:19.243

No answers