title: Download latest file from remote server using curl
body: <p>I'm able to download the file successfully using the following curl command.</p>
  
  <pre><code>curl -u user:pass -k "https://website.com/remote/path/remotefile.zip" -o /local/path/file.zip
  </code></pre>
  
  <p>Ideally, I'd like to automate this by getting the latest file programmatically. It's possible for more than one file to be uploaded per day. Each file's name is prefixed with a timestamp and there are multiple files within the directory.</p>
  
  <p>Example of directory contents and filenames:</p>
  
  <pre><code>20191102230243952_Appended-Constant_Filename.zip
  20191103040135476_Appended-Constant_Filename.zip
  20191103100132360_Appended-Constant_Filename.zip
  </code></pre>
  
  <p>Update from @FedonKadifeli's comment. If a request is made to the directory containing the files, the HTML output listing the files is returned.</p>
  
  <pre><code>curl -u user:pass -k "https://website.com/remote/path"
  </code></pre>
  
  <p>HTML Output</p>
  
  <pre class="lang-html prettyprint-override"><code>[...]
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td align="left"&gt;&amp;nbsp;&amp;nbsp;
              &lt;a href="/remote/path/20191102230243952_Appended-Constant_Filename.zip"&gt;&lt;tt&gt;20191102230243952_Appended-Constant_Filename.zip&lt;/tt&gt;&lt;/a&gt;
          &lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;66.6 kb&lt;/tt&gt;&lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;Sun, 03 Nov 2019 06:02:44 GMT&lt;/tt&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr bgcolor="#eeeeee"&gt;
          &lt;td align="left"&gt;&amp;nbsp;&amp;nbsp;
              &lt;a href="/remote/path/20191103040135476_Appended-Constant_Filename.zip"&gt;&lt;tt&gt;20191103040135476_Appended-Constant_Filename.zip&lt;/tt&gt;&lt;/a&gt;
          &lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;66.6 kb&lt;/tt&gt;&lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;Sun, 03 Nov 2019 12:01:35 GMT&lt;/tt&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td align="left"&gt;&amp;nbsp;&amp;nbsp;
              &lt;a href="/remote/path/20191103100132360_Appended-Constant_Filename.zip"&gt;&lt;tt&gt;20191103100132360_Appended-Constant_Filename.zip&lt;/tt&gt;&lt;/a&gt;
          &lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;66.5 kb&lt;/tt&gt;&lt;/td&gt;
          &lt;td align="right"&gt;&lt;tt&gt;Sun, 03 Nov 2019 18:01:32 GMT&lt;/tt&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  [...]
  </code></pre>