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.

  • 1
    Is 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 Sep 1 '18 at 0:29
  • 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 Sep 1 '18 at 3:58
  • Well you could use this approach: pastebin.com/feRb67eD it tries each of the array of extensions in turn, so you could add to that list. – HelpingHand Sep 1 '18 at 9:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.