Stand Alone: Reposition Columns In A Text File

Version 4

    This script will move columns in a text file that is formatted in fixed column widths (I.E. PartsLister BOM). User needs to edit script before using and is executed from the desktop. A backup file (*.bak) will be created at the same location as the input file.

     

    Edit the following at the top of the RepositionColumns.vbs file:

     

    'Define Col widths in number of characters, in order of the current file
    ' the "+" is to denote that the space is included in the width value
    ' NOTE: the argument to ColWidths shown below is 6 which represents 7 columns
    Dim ColWidths(6)
    ColWidths(0)=3+1
    ColWidths(1)=2+1
    ColWidths(2)=10+1
    ColWidths(3)=10+1
    ColWidths(4)=10+1
    ColWidths(5)=10+1
    ColWidths(6)=10+1

    'Define the new location of previous columns which must have same number of columns as ColWidths
    Dim NewOrder(6)

     

    'Example Current Order
    NewOrder(0)=0

    NewOrder(1)=1
    NewOrder(2)=2
    NewOrder(3)=3
    NewOrder(4)=4
    NewOrder(5)=5
    NewOrder(6)=6

     

    'Example Re-Order

    NewOrder(0)=6     'move column 6 to column 0

    NewOrder(1)=1
    NewOrder(2)=5     'move column 5 to column 2
    NewOrder(3)=3
    NewOrder(4)=4
    NewOrder(5)=2     'move column 2 to column 5
    NewOrder(6)=0     'move column 0 to column 6