export and import Gmail labels Print

  • Gmail label, gmail, gmail labels
  • 0

For Export :
 
Using the Labels Manager for Gmail Add-on
    1. Install the Labels Manager for Gmail add-on from the Google Workspace Marketplace.
    2. Open Google Sheets and the add-on's interface.
    3. Access the export function, then choose the "Export Labels (Light)" option.

 

  • Click on "export labels" to generate a snapshot of your labels, including their names and IDs, in a new Google Sheet. 

 

For Import :

  1. Go to Google Apps Script.

  2. Create a new project.

  3. Paste the following script:

 
function importLabels() { // Replace with your exported labels var labels = [ "Label1", "Label2", "Label3", "Label4" ]; for (var i = 0; i < labels.length; i++) { if (!GmailApp.getUserLabelByName(labels[i])) { GmailApp.createLabel(labels[i]); } } }
  1. Replace the labels array with your exported labels (you can copy them from your CSV).

  2. Click Run → Grant permissions → Labels will be created in Gmail

You can save the exported labels as a CSV file and open it in Notepad++

To add " in the beginning and the end of each line in the CSV file, follow the following instructions:

  1. Press Ctrl+H to bring up the Find/Replace Dialogue.
  2. Choose the Regular expression option near the bottom of the dialogue.

To add a " at the beginning of each line:

  1. Type ^ in the Find what textbox
  2. Type in the Replace with textbox
  3. Place cursor in the first line of the file to ensure all lines are affected
  4. Click Replace All button

To add a ", at the end of each line:

  1. Type $ in the Find what textbox
  2. Type ", in the Replace with textbox
  3. Place cursor in the first line of the file to ensure all lines are affected
  4. Click Replace All button

Now you can simply copy the text and paste it in the above-mentioned script.


Was this answer helpful?

« Back