0

How do I download all files starting with a specified name with wget?

For example, I have the link https://mylink.com/directory/.

There are the following files:

myFile_01_02.txt
myFile_01_03.txt
myFile3
yourFile
File1
secondFile

So, for example, I want to download all the files that starts with myFile. I read the help for the wget command but I didnt find anything useful. How can I do this?

3
  • 1
    The official docs on filtering for specific files. In short, the option would be something like --accept 'myFile*'. Apr 12 '19 at 14:12
  • @Anaksunaman so it doesnt work... I try wget -A "myFile_*[0-9]{2}_[0-9]{2}*.txt" https://mylink.com/directory/ but it doesnt help
    – Samvel
    Apr 12 '19 at 14:37
  • 1
    Use the accept-type option in conjunction with the mirroring or recursive options
    – ivanivan
    Apr 12 '19 at 15:04
2

As pointed out in the comments by @ivanivan, the -A (--accept) series of options must be used in conjunction with the -m (mirror) or -r (recursive) options. Therefore, interpreting your example command, the command you would likely want would be e.g. wget -m -nd -A "myFile_*_*.txt" https://mylink.com/directory/ (where -nd places all the matching files in a single directory rather than e.g. /mylink.com/directory/file.txt).

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.