|
#1
|
|||
|
|||
Prepend text to file
Hi
Has anyone got an idea on how I can prepend some text to a collection of files? I'm able to iterate through the collection fine using the Process Files functionality, and have tried using the replace in file functionality to prepend the text but have had no luck. I've tried using a regular expression starting with ^ but it seems to match the start of a line rather than start of the whole file. Unfortunately I have no tokens I can replace at the start of the file either. Any ideas welcome! Thanks, Chris. |
#2
|
|||
|
|||
Use a Replace in File action to match the entire file and put the prepend text before the replacement value (see attached).
|
#3
|
|||
|
|||
That's so simple I feel a bit daft now
Thanks for the help |
#4
|
|||
|
|||
prepend.bld does not work for me
prepend.bld does not work for me. I'm using Visual Build 6.1. Any clue why?
3/29/2006 1:25:53 PM: --------------------Starting Build: 'prepend'-------------------- 3/29/2006 1:25:54 PM: Building project step 'Project steps'... 3/29/2006 1:25:54 PM: Building project step 'Create text file'... Creating file C:\DOCUME~1\MIKER~1.MTG\LOCALS~1\Temp\abc.txt 3/29/2006 1:25:55 PM: Building project step 'Show file'... File now contains: String1=Testing 1234 String2=blah 456 3/29/2006 1:25:55 PM: Building project step 'Replace values'... 1 match(es) found, 1 replacement(s) made in file 3/29/2006 1:25:55 PM: Building project step 'Show file'... File now contains: text to prepend String1=Testing 1234 String2=blah 456text to prepend 3/29/2006 1:25:55 PM: Build successfully completed. |
#5
|
|||
|
|||
Check Replace first match only on the Replace tab.
|
#6
|
|||
|
|||
Yay! This worked. I'm glad I found it. I was originally trying to solve my problem using Write Files. Unfortunately, Write Files only lets you append or overwrite. A possible enhancement for Write Files would be to add dropdown that lets you choose the operation you want to perform:
|
#7
|
|||
|
|||
Implemented in v9.7.
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|