title: Google Drive Links & File Names
body: <p>I am using google sheets script editor to  get the file names and urls from a folder of files. I have adapted this code (<a href="https://webapps.stackexchange.com/questions/88769/get-share-link-of-multiple-files-in-google-drive-to-put-in-spreadsheet?answertab=active#tab-top">https://webapps.stackexchange.com/questions/88769/get-share-link-of-multiple-files-in-google-drive-to-put-in-spreadsheet?answertab=active#tab-top</a>) to print the urls, but I'm not sure how to bring in the file names.</p>
  <p>The files are, for example,</p>
  <p>A.csv</p>
  <p>B.csv</p>
  <p>C.csv</p>
  <p>And I want to print</p>
  <p>Ids Urls</p>
  <p>A   <a href="https://drive.google.com/file/d/..." rel="nofollow noreferrer">https://drive.google.com/file/d/...</a>.</p>
  <p>B   <a href="https://drive.google.com/file/d/..." rel="nofollow noreferrer">https://drive.google.com/file/d/...</a>.</p>
  <p>B   <a href="https://drive.google.com/file/d/..." rel="nofollow noreferrer">https://drive.google.com/file/d/...</a>.</p>
  <p>Here is my code</p>
  <pre><code>function myFunction() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var s = ss.getActiveSheet();
    var c1 = s.getRange(&quot;B2&quot;);
    var c2 = s.getRange(&quot;A2&quot;)
    var fldr = DriveApp.getFolderById(&quot;14ZKphLE02f6tdyU7LGEjbEEfrfD89nJM&quot;);
    var files = fldr.getFiles();
    var urls = [], f, str;
    while (files.hasNext()) {
      f = files.next();
      str = '=hyperlink(&quot;' + f.getUrl() + '&quot;)';
      urls.push([str]);
    }
    s.getRange(c1.getRow(), c1.getColumn(), urls.length).setFormulas(urls);
    var ids = [], f, str;
    while (files.hasNext()) {
      f = files.next();
      str = 'f.getName()';
      ids.push([str])
    }
    s.getRange(c2.getRow(), c2.getColumn(), ids.length).setValues(ids);
  }
  </code></pre>
  <p>I am getting the error: &quot;The number of rows in the range must be at least 1.&quot;</p>