Hi
I have a large collection of text files where all I need to do is insert a line into the first line of each file - so that it becomes the new first line. I'm basically adding a header line. The header line will be the same for every file.
The first line of each text file is different. There is nothing there I can use as a mark. I don't see any obvious clues in WildEdit to do an insert of a text line as the first line of each text file in a folder.
I'm a new user of WildEdit. So I don't know all the tricks. I know TextPad.
Can WildEdit do this?
Thanks!
Adding a header to files
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
All I can come up with is one of my usual "if-it-works-no-matter-how-brutal" regex
Select the entire file and replace it like
Find what: .*
Replace with: header-string\n$0
I have no idea what happens if the files are very large but for your average code/html file you should be ok. Use the + instead of * if you don't want to touch empty files. Make sure the entire file gets selected, ie. clear the "'.' does not match a newline character" on the options panel. I'd like to see a better regex for this, perhaps I'm just missing a flash of the blinding obvious
Hope it helps.
Select the entire file and replace it like
Find what: .*
Replace with: header-string\n$0
I have no idea what happens if the files are very large but for your average code/html file you should be ok. Use the + instead of * if you don't want to touch empty files. Make sure the entire file gets selected, ie. clear the "'.' does not match a newline character" on the options panel. I'd like to see a better regex for this, perhaps I'm just missing a flash of the blinding obvious
Hope it helps.
Then I open up and see
the person fumbling here is me
a different way to be
the person fumbling here is me
a different way to be
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm
Adding a header to a file
There was reported a bug on this back in March 2005. Anyone know if it was fixed and/or how to simply add a header to a collection of files?
Thanks
Thanks
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
In my head, I'd do some cheap hack like shell out to a command prompt (Start->Run cmd or command depending on your flavor of Windows)
Change to the appropriate directory
dir /s /b *.foo > myScript.bat
Fire up TextPad and then write a macro/regex to change results from
The replace regex would be something like except replace the newlines with \n and have this be a single string
and then execute that batch script
Change to the appropriate directory
dir /s /b *.foo > myScript.bat
Fire up TextPad and then write a macro/regex to change results from
Code: Select all
F:\tmp\bin.txt
F:\tmp\brainbench_badQ.txt
F:\tmp\purge.txt
F:\tmp\purge2.txt
Code: Select all
copy F:\tmp\bin.txt F:\tmp\bin.txt.foo
echo My Cool String > F:\tmp\bin.txt
type F:\tmp\bin.txt.foo >> F:\tmp\bin.txt
del F:\tmp\bin.txt.foo
...
Code: Select all
copy $1 $1.foo
echo My Cool String > $1
type $1.foo >> $1
del $1.foo
I choose to fight with a sack of angry cats.