![]() |
|
|
|||||||
| Petri.co.il is happy to award auglan the title of Most Valuable Member !!! |
| Register | Calendar |
Search |
Today's Posts |
Mark Forums Read |
| Notices |
|
|
Batch Script to move text within filethis thread has 1 replies and has been viewed 746 times
|
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
Hi Guys,
This is my first post and hopefully not my last! I have a problem that i really hope you can help with? i need to move text within a text file from one line to a different line and location. Conversion Tool @RUN @UNT 1.0 1.0 @LQT 1 @PRD "STD" "Formula" @BAS "CLQD1" @CLR "PM 24764 RP1" @CAN "5 L" 4250 @FRM 4250 @CNT "03YEOX" 3.080209 "02WHIT" 246.416673 @LOG @END I need to take the text from line @FRM which on this occasion is 4250 and move it to @BAS "CLQD1" so when done it will look like this. Conversion Tool @RUN @UNT 1.0 1.0 @LQT 1 @PRD "STD" “Formula" @BAS "CLQD1" 4250 @CLR "PM 24764 RP1" @CAN "5 L" 4250 @FRM @CNT "03YEOX" 3.080209 "02WHIT" 246.416673 @LOG @END The number at @FRM could be anything from 1 to 25000 also if needed the line @FRM can keep the number also. I have written a script to monitor folders and move files after editing but just cannot get the grip on this. All help greatly appreciated. Last edited by grigman06; 21st August 2012 at 00:21.. |
|
#2
|
||||||||
|
||||||||
|
This biterscript will do that.
Code:
# Script MoveText
# Set file name
var str file
set $file = "C:/path/to/file.abc"
# Read entire file in.
var str content
cat $file > $content
# Extract (and remove) text after @FRM and before newline.
var str movedText
# We will use a temporary string variable for content movement.
var str temp
stex -c "^@FRM^]" $content > $temp
stex "]^\n^" $content > $movedText
set $content = $temp+$content
# Insert $movedText before newline, after @BAS.
# Again we will use the temporary string variable.
stex -c "^@BAS^]" $content > $temp
set $content = $temp + $movedText + $content
# Write content back to file.
echo $content > { echo $file }
Save the script in file C:/Scripts/MoveText.txt. Execute it with Code:
script "C:/Scripts/MoveText.txt" |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using batch script to write\delete symbols into a text file | igor7 | General Scripting | 1 | 17th October 2011 12:58 |
| Delete first four lines form a text file using batch script | vegafa69 | DOS Command Shell | 0 | 12th October 2011 20:51 |
| Need some help with batch script - redirect output into text file | igor7 | General Scripting | 7 | 25th May 2011 00:49 |
| using batch script to delete specific lines to end of file in a text file | v.prasad86 | General Scripting | 3 | 29th December 2009 00:06 |
| using batch script to delete or modify data in a text file | ttt123 | General Scripting | 7 | 24th July 2008 14:21 |