Could you post a Snippet that does find & replace across all files within a folder please?
I did find something similar, Google Scripts - Find and Replace Function that searches multiple documents
but that one search in every file in Google Drive, not within a folder. Since I'm only learning Google Apps Script by example now, I can't make that tiny step myself.
EDIT: Further on the replacing part.
The DocumentApp.openById
returns a type of Document
right?
However, I can't find the replaceText
method in the Document
type doc:
https://developers.google.com/apps-script/reference/document/document
Fine, I then dig deeper, and found another example,
Google Apps Script document not accessible by replaceText(), which indicates that the replaceText
method should be invoked from var body = doc.getActiveSection()
. However, I can't find the getActiveSection
method in the Document
type doc either.
Please help. thx
var doc = DocumentApp.openById('doc id'); var body = doc.getBody(); body.findText('searchPattern')
instead of body you can work with headers and footers... – Serge insas