title: How do I download a file to a newly created directory with curl on OS X?
body: <p>I am trying to download my Heroku backups to a folder.</p>
  
  <p>Downloading to the current folder like this works:</p>
  
  <pre><code>curl -o latest.dump `heroku pg:backups public-url`
  </code></pre>
  
  <p>But when I tried adding a <code>folders</code> path to <code>latest.dump</code> it looks like this:</p>
  
  <pre><code>$ curl -o /db-bkups/latest.dump `heroku pg:backups public-url`
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
    0 44318    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0Warning: Failed to create the file 
  Warning: /db-bkups/latest.dump: No such file 
  Warning: or directory
   36 44318   36 16384    0     0   9626      0  0:00:04  0:00:01  0:00:03  9626
  curl: (23) Failed writing body (0 != 16384)
  </code></pre>
  
  <p>Ideally, I would like it be saved and downloaded like this:</p>
  
  <pre><code>/db-bkups/nov-1-2016/timestamp-db.dump
  </code></pre>
  
  <p>Where the folder <code>nov-1-2016</code> is created dynamically when the cron is run, and the filename is the timestamp when the bkup was run.</p>