

wscript.exe d:\reverse-text-file.vbs and customize its icon and shortcut caption. In the Send To folder of your user account, create a shortcut to the VBScript with wscript.exe prefix - e.g. You may also place a VBScript shortcut to the Send To folder for easier access. Or wscript reverse_text_file.vbs "d:\logs\somefile.txt"Īlternately, drag the text file on the VBScript file to reverse the text file contents. To run the VBScript file, use the following command-line syntax:Ĭscript //nologo reverse_text_file.vbs "d:\logs\somefile.txt" Set objFile = objFSO.OpenTextFile(sFileName, ForWriting, TriStateTrue)įor i = Ubound(arrLines) To LBound(arrLines) Step -1 Set objFile = objFSO.OpenTextFile(sFileName, ForReading, TriStateTrue) Set objFSO = CreateObject("Scripting.FileSystemObject") reverse_text_file.vbs 'Script to reverse the lines in a text file. To do so, open Notepad, copy the following lines into it and save the file with. Make a VBScript file from the following contents. To reverse the order of the lines in a text file using PowerShell, use this command-line syntax from a PowerShell window: $x = Get-Content -Path "C:\Users\ramesh\Desktop\dism.log" Set-Content -Path "C:\Users\ramesh\Desktop\dism.log" -Value ($x) Here is a couple of useful sites: Sort Text Lines - Text Mechanic: There are several free online services to reverse the order of the lines in a text file for you. Reverse a Text File Using Different Ways in Windows Method 1: Using online portals (free) Note: As always, before proceeding, be sure to backup the original text file before manipulating it - e.g., using find/replace, or running a script or macro against a text file.
