将Google驱动器中的csv文件批量转换为Google表格 [英] Bulk convert csv files in Google drive to Google Sheets
问题描述
我正在尝试选择Google驱动器中的一些csv文件,并将其转换为Google表格文件.我知道可以使用打开"选项一个接一个地执行此操作,但是由于我有数百个文件,因此我正在寻找一种使用多选和转换来执行此操作的方法.
I'm trying to select a few csv files that are in my Google drive and convert them to Google Sheets files. I know that I can do this one by one using the Open option, but since I have hundreds of files, I'm looking for a way to do this using multi-select and convert.
推荐答案
我知道两种转换多个文件的方法,多重选择和转换"不是其中一种.
I know two ways to convert multiple files, and "multi-select and convert" is not one of them.
下载文件,然后再次上传,首先要在云端硬盘设置中启用转换上传".
Download the files, then upload again, having first enabled "convert uploads" in Drive settings.
使用 Apps脚本,可以将CSV文件自动转换为Google Spreadsheet格式.首先,将要转换的文件移动到文件夹并记下其ID(?id =
之后可共享链接的一部分).在以下脚本中使用文件夹ID.
Using an Apps Script, one can convert CSV files to Google Spreadsheet format automatically. First, move the files to be converted to a folder and take a note of its id (the part of the shareable link after ?id=
). Use the folder id in the following script.
function convert() {
var folder = DriveApp.getFolderById('folder id here');
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
Drive.Files.copy({}, file.getId(), {convert: true});
}
}
按照说明启用高级驱动器服务,脚本.最后,运行它.它将在给定文件夹中创建所有文件的转换后副本.
Follow the instructions to enable Advanced Drive Service, which is used by the script. Finally, run it. It will create converted copies of all files in the given folder.
这篇关于将Google驱动器中的csv文件批量转换为Google表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!