2014-09-20 90 views
0

我需要關於此Google AdWords腳本的幫助:https://developers.google.com/adwords/scripts/docs/solutions/keyword-performance。 每次我在Google AdWords帳戶(用於我的PPC廣告系列)中運行此腳本時,都會創建報告(電子表格)並將其保存在我的谷歌驅動器上。 我想將電子表格文件保存到我的谷歌驅動器上的特定子文件夾(例如Report/Campaign01)。我找到了描述如何將電子表格保存到特定文件夾的文章。但我不知道如何編輯這個腳本並使用它。描述此功能的條款在這裏: http://www.freeadwordsscripts.com/2014/07/save-file-or-spreadsheet-in-specific.html將電子表格保存在GDrive的特定文件夾中

您能幫我解決問題嗎?

回答

0

假設你的文件夾和文件名是唯一的,可以使用保存到文件夾這樣

function myFunction() { 
    var folderIterator = DriveApp.getFoldersByName("YOUR_FOLDER_NAME"); 
    while (folderIterator.hasNext()) { 
    var folder = folderIterator.next(); 
    folder_count++; 
    var spreadsheet = SpreadsheetApp.create("YOUR_SPREADSHEET_NAME"); 

    // INSERT YOUR SPREADSHEET LOGIC HERE. 
    // YOU CAN CREATE YOUR SHEET HOWEVER YOU WANT, 
    // SO LONG AS YOU HAVE YOUR ACTIVE SPREADSHEET OBJECT. 

    // EITHER WAY, IT WILL SAVE TO YOUR ROOT DIRECTORY. 
    // THIS LOGIC MOVES YOUR FILE BY ID FROM ROOT TO YOUR SELECTED FOLDER. 

    var files = DriveApp.getRootFolder().getFilesByName("YOUR_SPREADSHEET_NAME"); 
    while (files.hasNext()) { 
     var file = files.next(); 
     if (spreadsheet.getId() == file.getId()) { 
     Logger.log("Found File! Moving..."); 
     folder.addFile(file); 
     DriveApp.getRootFolder().removeFile(file); 
     } else { 
     Logger.log("Wrong File, id[%s]" , file.getId()); 
     } 
    } 
    } 
} 
相關問題