UNPKG

dir-analysis-tool

Version:

A comprehensive cross-platform CLI tool for advanced directory analysis with file classification, duplicate detection, large file identification, interactive mode, HTML reports, and multiple export formats. Perfect for disk cleanup, storage audits, and pr

51 lines 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CSVExporter = void 0; class CSVExporter { static exportAnalysis(result) { const lines = []; lines.push('Type,Path,Size (Bytes),Size (Formatted),Count,Details'); lines.push(`Summary,${result.path},${result.totalSizeBytes},${result.totalSizeMB}MB,${result.files},Folders: ${result.folders}`); Object.entries(result.types).forEach(([type, count]) => { if (count > 0) { lines.push(`FileType,${type},-,-,${count},-`); } }); if (result.largeFiles && result.largeFiles.length > 0) { result.largeFiles.forEach(file => { lines.push(`LargeFile,"${file.path}",${file.size},"${file.sizeFormatted}",1,-`); }); } if (result.duplicateGroups && result.duplicateGroups.length > 0) { result.duplicateGroups.forEach((group, index) => { group.files.forEach((file, fileIndex) => { const details = fileIndex === 0 ? `Group ${index + 1}, Total files: ${group.files.length}, Wasted space: ${group.totalWastedSpaceFormatted}` : `Group ${index + 1} (duplicate)`; lines.push(`Duplicate,"${file}",${group.size},"${group.sizeFormatted}",1,"${details}"`); }); }); } return lines.join('\n'); } static exportLargeFiles(largeFiles) { const lines = []; lines.push('Path,Size (Bytes),Size (Formatted)'); largeFiles.forEach(file => { lines.push(`"${file.path}",${file.size},"${file.sizeFormatted}"`); }); return lines.join('\n'); } static exportDuplicates(duplicateGroups) { const lines = []; lines.push('Group,Path,Size (Bytes),Size (Formatted),Files in Group,Wasted Space'); duplicateGroups.forEach((group, index) => { group.files.forEach(file => { lines.push(`${index + 1},"${file}",${group.size},"${group.sizeFormatted}",${group.files.length},"${group.totalWastedSpaceFormatted}"`); }); }); return lines.join('\n'); } } exports.CSVExporter = CSVExporter; //# sourceMappingURL=export.js.map