function copyFolderContents_(source, target) {
// Iterate files in source folder
const filesIterator = source.getFiles()
while (filesIterator.hasNext()) {
const file = filesIterator.next()
// Make a copy of the file keeping the same name
file.makeCopy(file.getName(), target) // need to find python function replacing THIS LINE!!!!!!!!!!!!!!!!!!
}
}
const toCopy = DriveApp.getFolderById('')
const copyInto = DriveApp.getFolderById('')
const newFolder = copyInto.createFolder(toCopy.getName())
copyFolderContents_(toCopy, newFolder)
I trying to rewrite this app script into python, which only copies the file but not the folder into another locatioN
is there any pydrive or vanilla HTTP restful API that could replace file.makeCopy(file.getName(), target)
?
After visiting ref , seems this restful API doesn't have a target that I could specified.
The parent[]
parameter in the request body of Files:copy is the same as the destination in makeCopy(name, destination).
Here I have a folder named 68759008 which has the sample document:
and here is the destination folder I want my sample document to be copied.
Request Parameter:
In the request parameter, I only inserted the file ID of the sample document
Request Body:
{
"parents": [
"Insert Destination folder ID here"
],
"name": "68759008_TEST_DOC_COPY"
}
Response:
Output:
There are two options to obtain the parent ID or the destination folder ID:
https://drive.google.com/drive/folders/
mimeType
should be application/vnd.google-apps.folder
Files:list Example: