Random text in multiple files
- 
 Hello, I have several lists of names (+100 lists) and I want to make them in random order : - Raphaël NAME
- PATRICK NAME
- Louis NAME
- Emma NAME
- Gabriel NAME
 by - Raphaël NAME
- PATRICK NAME
- Louis NAME
- Emma NAME
- Gabriel NAME
 I found this script “npp-randomizelines” on: https://github.com/ethanpil/npp-randomizelines The execution of this script applies only in the first tab, the rest of the tabs don’t make any changes. Can someone help me? Thank you. 
- 
 Here’s a changed version of that script that works on ALL files open in the primary view of Notepad++ – make sure you have open ONLY the files you want randomized before running! # -*- coding: utf-8 -*- from Npp import editor, notepad import random for (filename, bufferID, index, view) in notepad.getFiles(): editor.beginUndoAction() notepad.activateFile(filename) EOLchar = ['\r\n', '\r', '\n'][editor.getEOLMode()] rawtext = str(editor.getText()) rawtextlines = rawtext.splitlines() random.shuffle(rawtextlines) randomizedtext = EOLchar.join(rawtextlines) editor.setText(randomizedtext) editor.endUndoAction()– 
 Moderator EDIT (2024-Jan-14): The author of the script has found a fairly serious bug with the code published here for those that use Mac-style or Linux-style line-endings in their files. The logic for Mac and Linux was reversed, and thus if the script was used on one type of file, the line-endings for the opposite type of file could end up in the file after the script is run. This is insidious, because unless one works with visible line-endings turned on, this is likely not noticed. Some detail on the problem is HERE. The script above has been corrected per that instruction.
- 
 
- 
 If you’ve used a script in this thread, you might want to double check your copy of it for a bug I’ve discovered. 
 Look to previous postings in this topic thread where the script has been changed – find the textmoderator edit (2024-Jan-14).
 There’s a link there that describes the bug in more detail, and shows what needs to be changed in an old copy (or you can simply grab a copy of the current version).

