Git Product home page Git Product logo

zipfolder's Introduction

ZipFolder

MIT License

Overview

This is a library for zipping a folder using Google Apps Scripts.

Description

When users manually download a folder on Google Drive, users can download all files in the folder as a zip file using the web interface. There are zip tools in Class Utilities of Google Apps Script. However, the zip tools cannot create a zip file from a folder. And it cannot retrieve all files included any folders in a folder. So I created this. This library works like almost the same to the web interface using GAS.

Feature

  • Retrieve all files in a folder. If there are folders in the folder, this library retrieves all files in all folders.
  • Google Docs of Spreadsheet, Document and Slide which are included in the folder are converted to Excel, Word and Powerpoint format, respectively.
  • Standalone scripts (projects) which are included in the folder are converted to JSON.
  • Other types (images, text data and so on) are not converted.
  • Google Form is not retrieved. Because it cannot be converted to export.

Library's project key

1q5FY5UxNpFNYxtd-LZgIjchicKq1BfDCVPbOwA0BDiL6zfCTxjfe-Puz

How to install

Installing is done. You can use ZipFolder.

Usage

var blob = ZipFolder.zip(folderId);
DriveApp.createFile(blob);

or

var blob = ZipFolder.zip(folderId, "_");
DriveApp.createFile(blob);

"_" is a delimiter between folder names. You can use freely various delimiters. If this is given, folder tree is used as a prefix of filename when there are folders in the folderId. If this is not given, the prefix is not used. For example, when there is /folder1/folder2/folder3/file1. When var blob = ZipFolder.zip(### ID of folder1 ###, "_") is used, filename will be folder2_folder3_file1. folder1 is used as the filename of zip file.

You can also see the documents at the following URL.

https://script.google.com/macros/library/versions/d/1q5FY5UxNpFNYxtd-LZgIjchicKq1BfDCVPbOwA0BDiL6zfCTxjfe-Puz

Option for preventing the duplicated filenames when the Google Docs is converted

var blob = ZipFolder.zip(folderId, null, { noExtension: true });
DriveApp.createFile(blob);

or

var blob = ZipFolder.zip(folderId, "_", { noExtension: true });
DriveApp.createFile(blob);

In this case, the files converted from Google Docs to Microsoft Docs have no extension of the filename. Please be careful this.

For your applications

For example, by deploying as Web Apps, this can be used as an API for zipping folders.

Licence

MIT

Author

Tanaike

If you have any questions and commissions for me, feel free to tell me.

Update History

TOP

zipfolder's People

Contributors

tanaikech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

aplater mr-nit

zipfolder's Issues

Crashes

When I use your library, I get this error:

Comparison method violates its general contract. (line 95, file "Code", project "ZipFolder")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.