In Google App Script I am doing an algorithm that consists in searching a file in the google drive and recording its URL for future use. To find the file I use the following sequence of instructions:
var files = DriveApp.searchFiles('title contains variable');
while (files.hasNext())
{
var file = files.next();
var dato = file.getUrl();
}
A variable that has a string of text inside is the name of the file that I want to search.
This instruction does not work for me. However, if I put in the place where the variable is the name I want to find in double quotes, everything works correctly. But the name I want to search can not be typed because I want to do it automatically without needing to write the name. And that name is within the value of the variable. Also, within a variable is the name in double quotes because it recognizes it as a text string.
I have tried writing variable without quotes like this in the example, in double quotes ("variable"), in single quotes ('variable') and none of the 3 works.
Can you tell me how I can make the instruction take variable and work?