I have the following situation, I have in my google drive several directories that have the same name. These are located in another directory with a different name than this if it would be different.
Example:
- EME/2019-04-APR
- JBL/2019-04-APR
The root directories are EME and JBL and inside it I have the directory that is repeated to me 2019-04-ABR . The problem that is being presented to me is that when I want it to give me the id of the 2019-04-ABR directory that is inside EME , it gives me the JBL one . It asks me the following how I can obtain the id of the directory that is inside EME when I require it and vice versa. Here I leave the code to see if you can help me.
Thanks.
$pageToken = null;
do {
$response = $driveService->files->listFiles(array(
'q' => mimeType='application/vnd.google-apps.folder' and name contains '2019-04-ABR',
'spaces' => 'drive',
'pageToken' => $pageToken,
'fields' => 'nextPageToken, files(id, name)',
));
foreach ($response->files as $file) {
$idFolder = $file->id;
}
$pageToken = $repsonse->pageToken;
} while ($pageToken != null);
According to the official documentation , you need to specify within which folder you want to search. When this specification is omitted, the returned result is the first one found.
To fix your problem, first in the Google Drive interface, open the EME folder and copy the id .
Then simply modify your code to look like this:
In this way you will be specifying within which specific folder you want to perform the search.