Сам разобрался, может кому-то будет полезно, вот готовый код, выполнять в кубике node.js (я выполнял в node18) .... кстати, больше 80% кода сгенерирована нейронкой https://chat.openai.com/chat
Задача выполняется двумя кубиками node.js
1) Сначала ищем из каталога все папки и переворачиваем этот список . Полученный список сохраняем в [[SPISOK]]
// Step 1 // Get the path to the "D:\\2 отправленое\\АНАЛИЗ" folder const path = "D:\\2 отправленое\\АНАЛИЗ"; // Create an empty list to store the paths to the folders inside the "creep-analysis" folder let spisok = []; // Use the fs (file system) module to read the contents of the "creep-analysis" folder const fs = require('fs'); const files = fs.readdirSync(path); // Loop through the contents of the "creep-analysis" folder and add the paths to the folders to the "spisok" list files.forEach((file) => { // Check if the current item is a folder if (fs.lstatSync(path + '/' + file).isDirectory()) { // Add the path to the folder to the "spisok" list spisok.push(path + '/' + file); } }); // Step 2 // Sort the "spisok" list in descending order by the number that each folder name starts with spisok.sort((a, b) => { // Get the folder name from the path of each item in the list const folderNameA = a.split('/').pop(); const folderNameB = b.split('/').pop(); // Extract the number that each folder name starts with const numberA = parseInt(folderNameA.match(/^\d+/)[0]); const numberB = parseInt(folderNameB.match(/^\d+/)[0]); // Compare the numbers and sort the list in descending order return numberB - numberA; }); // Step 3 // Save the sorted "spisok" list to the "itog" variable [[SPISOK]] = spisok;2) Далее ищем папку которая имеет вес меньше 1 мб и при условии что в каталоге где она лежит следующей будет папка с весом >=100мб
Готовый рабочий код, полный путь к итоговой папке сохраняется в [[PYT_K_PROSHLOY_PYSTOY_PAPKE]]:
