сам разобрался в, вот готовый код:
// 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;