Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
Búsqueda de archivos basada en una matriz de nombres de archivos y recuperación de propiedades de archivos para registrarlos en una hoja - Google App Scripts

He estado tratando de resolver esto, pero soy nuevo en la programación. Quiero obtener todos los nombres de archivo de una carpeta temporal y filtrarlos con los nombres de archivo que se han registrado previamente en una hoja junto con otras propiedades de archivo (tamaño, fecha de modificación, identificación, URL).

Después de mantener solo los nombres de archivo en la matriz que aún no están en la lista, me gustaría recuperar los archivos que tienen estos nombres de mi carpeta temporal y obtener sus propiedades de archivo para agregar una nueva fila a la hoja con el nombre, tamaño, fecha de modificación, id, url).

Esto es lo que tengo hasta ahora:

 const invoiceLog = SpreadsheetApp.openById('SPREADSHEETID').getSheetByName('invoicedata'); const invoiceDispatcherLog = SpreadsheetApp.openById('SPREADSHEETID').getSheetByName('invoicedispatcherlog'); const tempInvoiceFolder = DriveApp.getFolderById('TEMPFOLDERID'); const invoiceFolder2021 = DriveApp.getFolderById('INVOICEFOLDERID'); function invoiceLogger () { // get new Invoices from tempFolder and make an array of their names let newInvoiceFileNames = []; let newInvoices = tempInvoiceFolder.getFiles(); while (newInvoices.hasNext()){ file =newInvoices.next(); let row = [] row.push(file.getName()) newInvoiceFileNames.push(row); Logger.log(row) } // filter the array of new invoices by existing invoice names in the invoice log let newInvoiceFileNamesFlat = newInvoiceFileNames.map(function(row) {return row [0];}); let existingInvoices = invoiceLog.getRange('A2:A').getValues(); let existingInvoicesFlat = existingInvoices.map(function(row) {return row [0];}); var cleanInvoiceNames = newInvoiceFileNamesFlat.filter(item => !existingInvoicesFlat.includes(item)) //let markedFiles = DriveApp.getFilesByName(cleanInvoiceNames); cleanInvoiceNames.forEach(SearchFiles)

Estoy seguro de que tengo algunas redundancias aquí y no estoy en un punto en el que pueda apreciar completamente todos los aspectos de cómo las funciones y los métodos se entrelazan, pero estaría enormemente agradecido por alguna orientación. Por favor, hágame saber si algo de esto no está claro y si puedo proporcionar más información.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Actualizar datos de factura

 function updateInvoiceData() { const ss = SpreadsheetApp.openById('ssid'); const ish = ss.getSheetByName('invoicedata'); const lnames = ish.getRange(2, 1, ish.getLastRow() - 1).getValues().filter(r => r[0]).flat();//listed names const ifldr = DriveApp.getFolderById('TEMPFOLDERID'); let info = [];//new names let ifiles = ifldr.getFiles(); while (ifiles.hasNext()) { let ifile = ifiles.next(); let n = ifile.getName(); //if not already listed if(!~lnames.indexOf(n)) { info.push([n, ifile.getSize(),ifile.getDateCreated(),ifile.getId(),ifile.getUrl()]); } } ish.getRange(ish.getLastRow() + 1,1,info.length,info[0].length).setValues(info); }

bit a bit no (~)

Esto obtiene la fecha de modificación:

 function updateInvoiceData() { const ss = SpreadsheetApp.openById(gobj.globals.ssid); const ish = ss.getSheetByName('Sheet0'); const sr = 2;//data start row const lr = ish.getLastRow();//data last row let lnames; if(lr > 1) { lnames = ish.getRange(2, 1, ish.getLastRow() - 1).getValues().filter(r => r[0]).flat();//listed names } else { lnames = []; } const ifldr = DriveApp.getFolderById(gobj.globals.testfolderid); let info = [];//new names let ifiles = ifldr.getFiles(); while (ifiles.hasNext()) { let ifile = ifiles.next(); let n = ifile.getName(); //if not already listed if(!~lnames.indexOf(n)) { let d = JSON.parse(Drive.Files.get(ifile.getId())).modifiedDate; info.push([n, ifile.getSize(),d,ifile.getId(),ifile.getUrl()]); } } ish.getRange(lr + 1,1,info.length,info[0].length).setValues(info); }

Tienes que habilitar Drive API versión 2

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda