Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
How to copy individual files into folder directory at relevant search depth reading from Google Sheet

I managed to find a way to create a folder directory from reading a Google Sheet linked below.

https://docs.google.com/spreadsheets/d/1qgDd8PEmHSYz5IsN9banYBjbmAyoLLVe3WMnOvmHdlE/edit#gid=0

Now, my predicament is to transfer individual files into those newly created folders and the relevant search Depth. I thought this would be possible; however, I am now thinking it isn't hence the limited code below.

This is because for each file (Column C), I would need to read the source parent folder ID (Column D) and then convert this to the destination folder equivalent recorded in Column F. I'm not sure how I can go about doing this? Moreover, should the Google Sheet be sorted into folders and files in a first instance (Column C), ideally the solution should still work when files and folders are out of order.

I know this is not the best solution; however, I am looking for a solution I can understand in order to advance my understanding.

function copyFiles() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const ws = ss.getSheetByName('Details');
  const range = ws.getDataRange();
  const values = range.getValues();
  values.forEach(function(row, index) {
    if (row[2] == 'File'){

    } else {

    }
    })
}

Thank you in advance

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Assuming your data is well organized sequentially (based on files'id in column B)

function copyFiles() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const ws = ss.getSheetByName('Sheet1');
  const range = ws.getDataRange();
  const values = range.getValues();
  var parentID = ''
  values.forEach(r => {
    if (r[2] == 'Folder') { parentID = r[5] }
    else if (r[2] == 'File') {
      r[5] = DriveApp.getFileById(r[1]).makeCopy(r[0], DriveApp.getFolderById(parentID)).getId()
    }
  })
  range.setValues(values)
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda