1. Home
  2. Docs
  3. Google Toolkit
  4. Pro Tips
  5. How to Copy Folders and List file names in Google Drive

How to Copy Folders and List file names in Google Drive

Getting File Names From a Google Drive Folder.
There are a lot of tools which can list the file name in a folder. However, in Google Drive, there is not a plugin so far. But, a script is available to extract file names from the folder . I would like to share this tip to my team.I found that tip from the following website. So, feel free to check that link.

http://www.acrosswalls.org/ortext-datalinks/list-google-drive-folder-file-names-urls/

  1. Create a blanksheet
  2. Go to Tools/Script editor
  3. In the scripteditor, past the following code
// replace your-folder below with the folder for which you want a listing
function listFolderContents() {
  var foldername = 'your-folder';
  var folderlisting = 'listing of folder ' + foldername;
  
  var folders = DriveApp.getFoldersByName(foldername)
  var folder = folders.next();
  var contents = folder.getFiles();
  
  var ss = SpreadsheetApp.create(folderlisting);
  var sheet = ss.getActiveSheet();
  sheet.appendRow( ['name', 'link'] );
  
  var file;
  var name;
  var link;
  var row;
  while(contents.hasNext()) {
	file = contents.next();
	name = file.getName();
	link = file.getUrl();
	sheet.appendRow( [name, link] );	 
  }  
};
  1. You might need to change the ‘your-folder’ name with the name of your folder.
  2. Note that the folder should be in your own drive.
  3. If you click save and run , it will ask permission, just allow it.
  4. After that , you will see a new spreadsheet with ‘ list of files in your folder name’ in My Drive .
  5. Enjoy.

Copying a share folder into your ‘My Drive’

  1. You can copy a file which is shared with you.
  2. You can not copy the whole folder.
  3. There is an addon which can solve this problem.
  4. The name is Copy Folder.check out the link

https://chrome.google.com/webstore/detail/copy-folder/kfbicpdhiofpicipfggljdhjokjblnhl?hl=en

  1. When you run it, it will ask you to choose a folder you ‘d like to copy.
  2. My suggestion is to open that folder before you run the addon.
  3. That is because you will face trouble to find the exact folder from a lot of folders in your drive.
  4. So if you click sort button and (Sort last opened by me ), it will make alot easier to navigate.
  5. Then, you will see a newly copied folder in MyDrive.
  6. ENJOY!!!

Nyein Chan Ko Ko