Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query for list of files and folders in root directory

I would like to get a list of files and folders in the root directory without having to sort through all the files. Is there a query that would do this?

like image 491
PizzaPanther Avatar asked Jul 29 '12 02:07

PizzaPanther


People also ask

What types of files and folders are stored in the root directory?

The root directory is the topmost folder in a file system. It contains all of the other folders and files in the system. The folders in the root directory are used for specific purposes, such as storing user data or application files.

How many files are in a root directory?

The maximum number of files is one upper limit. This limit is either 2^23-1 (according to many driver implementations) or 2^48 -1 (according to the MFT_REF structure).


2 Answers

The root folder can also be addressed with a special alias named "root", so you can get all files and folders in the root with the following query:

https://www.googleapis.com/drive/v2/files?q='root' in parents

Remember to escape the URL if not using one of the client libraries (they automatically take care of it).

For more details about the search query language, check https://developers.google.com/drive/search-parameters

like image 110
Claudio Cherubino Avatar answered Oct 26 '22 01:10

Claudio Cherubino


This code will display all files and folder of your ROOT DIRECTORY. just copy and paste this code and you will get all your root's file and folder.

 List<File> result = new ArrayList<File>();
    Files.List request = null;

    try {
          request = mService.files().list();
          FileList files = request.setQ("'root' in parents and trashed=false").execute();
          result.addAll(files.getItems());          
          request.setPageToken(files.getNextPageToken());
        } 
      catch (IOException e)
      {
        System.out.println("An error occurred: " + e);
        request.setPageToken(null);
      }

 //Print out all the files and folder of root Directory  
  for(File f:result)
  {
      System.out.println("recvd data are: "+f.getTitle());
  }
like image 37
Pir Fahim Shah Avatar answered Oct 26 '22 02:10

Pir Fahim Shah