Question: I am trying to write a script to get the URL of a specific yet dynamic Google Document in Drive. The Google Document is created every Tuesday with its date at the end of the title of the Google Document. 

"TypeError: Cannot find function getUrl in object FileIterator." error shows on line `var agendaURL = file.getUrl();`. Not sure how to debug this.

```
  var ssUrl = 'LINK BUFFERED';
  var sheetName = 'SHEET1';   // name of sheet to use
  var rangeName = 'C30';    // range of values to include 
  var dateRange = SpreadsheetApp.openByUrl(ssUrl)
                                .getSheetByName(sheetName)
                                .getRange(rangeName)
                                .getValues(); 

  // NEED TO find how to find file by name below!
  var file = DriveApp.getFilesByName("Weekly Agenda | " +dateRange);
  var agendaURL = file.getUrl();

```

Answer: 
It is because you need to iterate through all of the files that meet the search criteria. The solution is here: <https://developers.google.com/apps-script/reference/drive/drive-app>

```
   var files = DriveApp.getFilesByName("Weekly Agenda | " +dateRange);
     while (files.hasNext()) {
       var file = files.next();
       var agendaURL = file.getUrl();  
       return agendaURL //for first one, or you can return each one, push to an array, etc...
    }

```
The value which got by DriveApp.getFilesByName() is FileIterator. So it is necessary to retrieve the filename from the value as follows. 

```
var filename = "Weekly Agenda | " + dateRange;
var file = DriveApp.getFilesByName(filename);
while (file.hasNext()) {
  var file = files.next();
  if (file.getName() == filename) {
    var agendaURL = file.getUrl();
  }
}

```