Results 1 to 4 of 4

Thread: Split long text into fixed width with Powershell

  1. #1
    Join Date
    Feb 2009
    Posts
    66

    Split long text into fixed width with Powershell

    hi friends,

    I have the document in which the text appears continously as we see in the notepad. I want to split this long text into the fixed width of text lines so that the document looks nicely formatted. How can I do this with the Powershell ?

  2. #2
    Join Date
    May 2008
    Posts
    3,316

    Re: Split long text into fixed width with Powershell

    Try this:

    get-content longfile.txt | select-string 2003 | out-file outfile.txt -width _____.

    In the blank space, specify the lower value say 150 or 200 so that the next line of the document starts after every that(value) number of characters.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,139

    Re: Split long text into fixed width with Powershell

    Go to the following link and get all the necessary details and information about splitting the file content into words.

    Click here.

  4. #4
    Join Date
    Apr 2008
    Posts
    4,088

    Re: Split long text into fixed width with Powershell

    One of the important factors is to remove the excess spaces. If the source data is really fixed-width, you should really remove the spaces only AFTER you’ve parsed the line.

    you can use a regex split on one or more spaces- [regex] :: Split($s, ” +”)

    This is fixed with data, hence it would be safer to select by substring and then trim the excess spaces.

Similar Threads

  1. Small width of cell has made the text unreadable in NIS 2011 beta
    By Leslie f in forum Networking & Security
    Replies: 4
    Last Post: 08-09-2011, 11:09 PM
  2. How to rename .Bat-append fixed text in c#
    By Omanand in forum Software Development
    Replies: 5
    Last Post: 05-07-2011, 07:24 PM
  3. VBScript to split a text file evenly in three
    By Kazz013 in forum Software Development
    Replies: 3
    Last Post: 16-12-2010, 06:35 PM
  4. Powershell script to parse system logs in text file
    By SADIQ in forum Operating Systems
    Replies: 2
    Last Post: 02-06-2009, 07:05 PM
  5. Fixed height & width in new window
    By Gustak in forum Customize Desktop
    Replies: 2
    Last Post: 08-12-2008, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,259,529.32297 seconds with 17 queries