index.js aktualisiert
This commit is contained in:
parent
1250b6c328
commit
160b56634c
73
index.js
73
index.js
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Projekt: File Renamer CLI
|
||||
* Beschreibung: Ein rekursives CLI-Tool zum Umbenennen von Dateien mit Suffix.
|
||||
* Autor: M_Viper
|
||||
* Lizenz: MIT
|
||||
* GitHub: https://git.viper.ipv64.net/M_Viper/file-renamer-cli
|
||||
* Webseite: https://m-viper.de
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
@ -5,6 +14,68 @@ const readline = require('readline');
|
||||
|
||||
const configPath = path.join(os.homedir(), 'Documents', 'config.json');
|
||||
|
||||
// ================== Banner ==================
|
||||
function greenMessage(text) {
|
||||
console.log('\x1b[32m%s\x1b[0m', text);
|
||||
}
|
||||
|
||||
function centerText(text, width) {
|
||||
const len = text.length;
|
||||
if (len >= width) return text;
|
||||
const leftPadding = Math.floor((width - len) / 2);
|
||||
return ' '.repeat(leftPadding) + text;
|
||||
}
|
||||
|
||||
function showAsciiLogo() {
|
||||
const width = process.stdout.columns || 80; // Terminalbreite, fallback 80
|
||||
|
||||
const logoLines = [
|
||||
'███████╗██╗██╗ ███████╗███╗ ██╗ █████╗ ███╗ ███╗███████╗ ██████╗██╗ ██╗',
|
||||
'██╔════╝██║██║ ██╔════╝████╗ ██║██╔══██╗████╗ ████║██╔════╝ ██╔════╝██║ ██║',
|
||||
'█████╗ ██║██║ █████╗ ██╔██╗ ██║███████║██╔████╔██║█████╗ ██║ ██║ ██║',
|
||||
'██╔══╝ ██║██║ ██╔══╝ ██║╚██╗██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ██║ ██║',
|
||||
'██║ ██║███████╗███████╗██║ ╚████║██║ ██║██║ ╚═╝ ██║███████╗ ╚██████╗███████╗██║',
|
||||
'╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚══════╝╚═╝',
|
||||
];
|
||||
|
||||
console.log('\x1b[32m'); // grün starten
|
||||
for (const line of logoLines) {
|
||||
console.log(centerText(line, width));
|
||||
}
|
||||
console.log('\x1b[0m'); // Farbe zurücksetzen
|
||||
console.log('');
|
||||
}
|
||||
|
||||
function showBanner() {
|
||||
console.clear();
|
||||
showAsciiLogo();
|
||||
|
||||
const width = process.stdout.columns || 60; // Breite des Terminals, fallback 60
|
||||
|
||||
const bannerLines = [
|
||||
'Version 1.0',
|
||||
'Script by',
|
||||
'@M_Viper',
|
||||
'__________________________',
|
||||
'',
|
||||
'Git: https://git.viper.ipv64.net/M_Viper/file-renamer-cli',
|
||||
];
|
||||
|
||||
// Obere Rahmenlinie
|
||||
greenMessage('╔' + '═'.repeat(width - 2) + '╗');
|
||||
|
||||
// Bannerzeilen mit Rahmen und Zentrierung
|
||||
for (const line of bannerLines) {
|
||||
const centered = centerText(line, width - 4); // 4 wegen Rahmen links und rechts + Leerzeichen
|
||||
greenMessage('║ ' + centered + ' ║');
|
||||
}
|
||||
|
||||
// Untere Rahmenlinie
|
||||
greenMessage('╚' + '═'.repeat(width - 2) + '╝');
|
||||
greenMessage('');
|
||||
}
|
||||
// ============================================
|
||||
|
||||
function saveConfig(config) {
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||
}
|
||||
@ -122,6 +193,8 @@ function umbenennenSync(pfad, suffix) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
showBanner(); // Banner anzeigen
|
||||
|
||||
const config = await getConfig();
|
||||
umbenennenSync(config.folderPath, config.suffix);
|
||||
console.log('Fertig!');
|
||||
|
Loading…
x
Reference in New Issue
Block a user