Filter
Exclude
Time range
-
Near
21 Sep 2024
Forgot I can just paste it here. It's around 150 lines, it SHOULD work with any project with node. It'll recursively add files that belong to any folder you put in the keep list and it will ignore any file extensions in the condition. const fs = require('fs'); const path = require('path'); async function selectFiles(currentDir, keepList, isWithinKeptFolder = false) { const selectedFiles = []; const items = await fs.promises.readdir(currentDir); for (const item of items) { const itemPath = path.join(currentDir, item); let stats; try { stats = await fs.promises.stat(itemPath); } catch (error) { console.warn(`Warning: Could not access ${itemPath}. Skipping.`); continue; } if (stats.isDirectory()) { if (isWithinKeptFolder || keepList.folders.includes(item)) { // If already within a kept folder or the folder is in the keep list selectedFiles.push(...await selectFiles(itemPath, keepList, true)); } } else { // Ignore files with .txt extension if (path.extname(item) === '.txt' || itemPath.includes('index.json') || itemPath.includes('courses.json')) { console.log(`Ignoring .txt file: ${itemPath}`); continue; } if (isWithinKeptFolder || keepList.files.includes(item)) { // If within a kept folder or the file is in the keep list selectedFiles.push(itemPath); } } } return selectedFiles; } async function mergeFiles(selectedFiles, outputDirPath) { let mergedContent = ''; let lineCount = 0; let fileIndex = 1; for (const filePath of selectedFiles) { try { let fileContent = await fs.promises.readFile(filePath, 'utf-8'); const relativePath = path.relative(process.cwd(), filePath); // Remove leading/trailing whitespace and reduce multiple newlines to a single newline fileContent = fileContent .replace(/\s $/, '') // Remove trailing whitespace .replace(/^\s /, '') // Remove leading whitespace .replace(/\n{2,}/g, '\n'); // Replace multiple newlines with a single newline const sectionHeader = `\n\n===== ${relativePath.toUpperCase()} CODE BELOW =====\n`; const fullContent = sectionHeader fileContent '\n'; const contentLines = fullContent.split('\n').length; // If adding this content will exceed 1000 lines, write to a new file if (lineCount contentLines > 1000) { await writeFile(outputDirPath, fileIndex, mergedContent); fileIndex ; mergedContent = ''; // Reset the content lineCount = 0; // Reset the line count } mergedContent = fullContent; lineCount = contentLines; } catch (error) { console.warn(`Warning: Could not read file ${filePath}. Skipping.`); } } // Write the remaining content to a new file if (mergedContent) { await writeFile(outputDirPath, fileIndex, mergedContent); } } async function writeFile(outputDirPath, fileIndex, content) { const outputFilePath = path.join(outputDirPath, `repo-transcript-${fileIndex}.txt`); try { await fs.promises.writeFile(outputFilePath, content, 'utf-8'); console.log(`Saved part ${fileIndex} to: ${outputFilePath}`); } catch (error) { console.error(`Error writing to file ${outputFilePath}:`, error); } } async function createOutputDirectory(outputDirPath) { try { await fs.promises.access(outputDirPath); } catch (error) { try { await fs.promises.mkdir(outputDirPath, { recursive: true }); console.log(`Created output directory: ${outputDirPath}`); } catch (mkdirError) { console.error(`Error creating directory ${outputDirPath}:`, mkdirError); process.exit(1); } } } async function main() { const currentDir = process.cwd(); console.log('Generating merged transcript of the project...'); // Define folders and files to keep here const keepList = { folders: [ 'src', 'environments' // Add more folder names to keep as needed ], files: [ 'package.json', 'angular.json', 'ngsw-config.json', 'tailwind.config.json', 'tsconfig.app.json', 'tsconfig.json', 'tsconfig.spec.json', 'index.html', 'main.ts' // Add more file names to keep as needed ], }; let selectedFiles; try { selectedFiles = await selectFiles(currentDir, keepList); } catch (error) { console.error('Error selecting files:', error); process.exit(1); } const outputDirName = 'repo_transcripts'; const outputDirPath = path.join(currentDir, outputDirName); await createOutputDirectory(outputDirPath); await mergeFiles(selectedFiles, outputDirPath); } main().catch((error) => { console.error('An unexpected error occurred:', error); });

2
1
12
323
Nieuwe video's opnemen voor een blog over het samenvoegen van bestanden in SPSS. Link naar blog in bio. #spss #studenten #SPSSKONING #spsstips #spssfordummies #ondernemen #mergefilesinstagram.com/p/BuTQqH0jB8H/…

@StartupRanking allow the user "MergeFil.es" to claim rights over "mergefil.es" (@mergefiles) in startupranking.com.

1
1
21 Aug 2016
@n_talia17 this is us for the next few weeks as we #mergefiles #winewineandmorewine
1
1
Replying to @mergefiles
It's @plamena_gn you need to thank, she recommended you :)
1
MergeFiles by PIEBALDconsult ift.tt/1TOogP0

2
MergeFiles: онлайн объединение файлов разного формата в один документ lifehacker.ru/2014/03/09/mer…

3
24
8 Mar 2014
Indispensable : convertir et assembler des fichiers Word, Excel, Powerpoint, PDF, HTML et TXT avec MergeFiles bit.ly/1ktXluD

4
3
5 Mar 2014
MergeFiles, un outil pour convertir/assembler des fichiers doc, docx, xls, xlsx, ppt, pptx, pdf, html, txt et jpg bit.ly/1ktXluD

1
1
4 Mar 2014
Convertir et assembler des fichiers Word, Excel, Powerpoint, PDF, HTML et TXT avec MergeFiles bit.ly/1kSom7U

1
3
4 Mar 2014
Attention pépite : convertir et assembler des fichiers Word, Excel, Powerpoint, PDF, HTML et TXT avec MergeFiles→ bit.ly/1ktXluD

7
11
MergeFiles – Para juntar varios documentos en un solo wwhts.com/NlGxYI

1
9
14