Kleines Snipppet ohne Dependencies.
Ersetzt oldString mit newString, bei allen Dateien im Ordner.
001_file_replace_string commands
Keine weitere Überprüfung! Es ist ein reines Arbeitstool, welches bewusst benutzt werden sollte.
AnwendungDatei 001_file_replace_string.js in das Verzeichnis kopieren.
001_file_replace_string.js Archiv 2018 - 2021 Part 1 von 17.zip Archiv 2018 - 2021 Part 2 von 17.zip Archiv 2018 - 2021 Part 3 von 17.zip [ ---- ... ----] node .\001_folder_replace_string.jsTerminal wartet auf Input:
### ### oldString;;;newString ### ### Album Fotos klein Karen;;;karen_klein Ctrl+C to cancel Bitte eingeben:Bitte eingeben: Archiv;;;Backup
Ersetzt Archiv mit Backup.
Es versucht alles zu Überschreiben. Auch sich selbst. Bewusst anwenden.
Bitte eingeben: Archiv;;;Backup 001_folder_replace_string.js => 001_folder_replace_string.js Archiv 2018 - 2021 Part 10 von 17.zip => Backup 2018 - 2021 Part 10 von 17.zip Archiv 2018 - 2021 Part 1 von 17.zip => Backup 2018 - 2021 Part 1 von 17.zip Archiv 2018 - 2021 Part 11 von 17.zip => Backup 2018 - 2021 Part 11 von 17.zip Archiv 2018 - 2021 Part 12 von 17.zip => Backup 2018 - 2021 Part 12 von 17.zip Archiv 2018 - 2021 Part 13 von 17.zip => Backup 2018 - 2021 Part 13 von 17.zip Archiv 2018 - 2021 Part 14 von 17.zip => Backup 2018 - 2021 Part 14 von 17.zip Archiv 2018 - 2021 Part 17 von 17.zip => Backup 2018 - 2021 Part 17 von 17.zip Archiv 2018 - 2021 Part 15 von 17.zip => Backup 2018 - 2021 Part 15 von 17.zip Archiv 2018 - 2021 Part 16 von 17.zip => Backup 2018 - 2021 Part 16 von 17.zip Archiv 2018 - 2021 Part 2 von 17.zip => Backup 2018 - 2021 Part 2 von 17.zip Archiv 2018 - 2021 Part 5 von 17.zip => Backup 2018 - 2021 Part 5 von 17.zip Archiv 2018 - 2021 Part 3 von 17.zip => Backup 2018 - 2021 Part 3 von 17.zip Archiv 2018 - 2021 Part 4 von 17.zip => Backup 2018 - 2021 Part 4 von 17.zip Archiv 2018 - 2021 Part 6 von 17.zip => Backup 2018 - 2021 Part 6 von 17.zip Archiv 2018 - 2021 Part 7 von 17.zip => Backup 2018 - 2021 Part 7 von 17.zip Archiv 2018 - 2021 Part 8 von 17.zip => Backup 2018 - 2021 Part 8 von 17.zip Archiv 2018 - 2021 Part 9 von 17.zip => Backup 2018 - 2021 Part 9 von 17.zip Sourcecode var fs = require('fs'); const readline = require('readline'); function askForInput(string) { const processor = readline.createInterface({ output: process.stdout, input: process.stdin }); return new Promise(resolve => processor.question(string, input => { processor.close(); resolve(input); })) } function replace(pattern){ var patterns = pattern.split(";;;"); fs.readdirSync('./').forEach(file => { var newfile = file.replace(patterns[0], patterns[1]); fs.rename(file, newfile, (err) => { if (err) throw err; console.log(file, ' => ', newfile); }); }); } async function main(){ const replacement_pattern = await askForInput("\n###\n### oldString;;;newString\n###\n### Album Fotos klein Karen;;;karen_klein\n\nCtrl+C to cancel\n\nBitte eingeben:"); replace(replacement_pattern); } main();Requires min Node v14.15.1
Getestet Windows