0

I have the problem.

Earlier I had the file for search in my own Google Drive. And the script worked.

function checkInFiles(){

  var nameJSON = 'jobToCAF';

  var files = DriveApp.searchFiles('title contains "' + nameJSON + '"');

  while (files.hasNext()) {
     var file = files.next();
     Logger.log(file.getName());

  }
}

Script searches for files named like 0080076042_jobToCAF.JSON.

The difference is that now the file is located in shared Google Drive and search doesn't work.

Can you help ?

Kos
  • 4,890
  • 9
  • 38
  • 42
  • Does this answer your question? [Accessing shared drive with DriveApp](https://stackoverflow.com/questions/58170053/accessing-shared-drive-with-driveapp) – J. G. Sep 08 '21 at 14:21
  • check the question I marked as duplicate – J. G. Sep 08 '21 at 14:22
  • @J. G. may be this is right answer but there is some different. the file format is json. What I must to set in mimeType:? and the search is by part of name of file, the file always uploads from one resource and don't have static id. How can I decide it? – Dmitriy Rudakov Sep 08 '21 at 14:29
  • @Kos may be in your resource there is the way to resolve the issue... I saw that I can get the TeamDrive.items like the array with data, and may be I can get one of this elements by searching by the part of name. It's just my thoughts, I wil try this way. What do you think about it? – Dmitriy Rudakov Sep 09 '21 at 04:57
  • function printMimeType(){ var gdrive = "xxxxxxx"; var file = DriveApp.getFileById(gdrive); console.log(file.getMimeType()); } is what you should use to find out the mimetype string for a json file, mimetype strings are usually something like "'application/cab', 'text/html', if I had to guess I would say json is going to be text/json but better to check a known file and be sure. – J. G. Sep 10 '21 at 13:56
  • thank you, but Kos gave me success way) – Dmitriy Rudakov Sep 10 '21 at 14:00

0 Answers0