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', '\n', '\r'][editor.getEOLMode()] rawtext = str(editor.getText()) rawtextlines = rawtext.splitlines() random.shuffle(rawtextlines) randomizedtext = EOLchar.join(rawtextlines) editor.setText(randomizedtext) editor.endUndoAction()
-