Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
Line 1
Line 2
Line 3
Line 4
Line 5

should become

Line 5
Line 4
Line 3
Line 2
Line 1

I need a notepad script to do this.

share|improve this question
    
Notepad is not scriptable, is it? –  grawity Dec 12 '11 at 18:32
add comment

5 Answers

If you have Perl installed you can use

perl -e 'print reverse <> ' filename > newfile

As in

$ cat file.txt
line 1
line 2
line 3
line 4
line 5
$ perl -e 'print reverse <>' file.txt > new.txt
$ cat new.txt
line 5
line 4
line 3
line 2
line 1

(its the same on Windows but use type instead of cat and use double-quotes (") in the perl command.)

You have tagged your question "notepad" and mentioned "notepad" in the text. If you want a solution using "notepad++", you should edit the question accordingly.

share|improve this answer
add comment

This is a three step process in Notepad++ using TextFX.

  1. Select the entire document (ctrl+A) (or the section you want to be reversed), and from the TextFX menu, select TextFX Tools -> Insert Line Numbers.
  2. From the TextFX menu, make sure that TextFX Tools -> +Sort ascending is unchecked and then select TextFX Tools -> Sort lines case sensitive (at column). This will reverse the order of the lines.
  3. From the TextFX menu, select TextFX Tools -> Delete Line Numbers or First Word, and you're done.

The Notepad app that ships with Windows is pretty much useless. There are many alternatives, but I prefer Notepad++.

share|improve this answer
add comment

Notepad, unless you mean some other than the one that comes with Windows OS, is not scriptable. Were you to use Vim, it would be simply

:g/^/m0
share|improve this answer
add comment

You could try tac which reverses line by line

tac filename
share|improve this answer
add comment

If you were after a ready made script, the script center has one contributed by the community (i.e. not written by Microsoft)

http://gallery.technet.microsoft.com/scriptcenter/55ba15dc-9933-4c9d-a2b0-524453a66343

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.