Adding a header to files

General questions about using WildEdit

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
Ryck
Posts: 50
Joined: Thu Mar 17, 2005 4:20 am

Adding a header to files

Post by Ryck »

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!
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

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 :roll:
Hope it helps.
Then I open up and see
the person fumbling here is me
a different way to be
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Hm.

I don't understand what's going wrong but doing what s_reynisson suggests adds the header-string to the start and the end of the file
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Same results here, posted a bug report from the support page. Thx for the pointer.
Then I open up and see
the person fumbling here is me
a different way to be
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

I was going to report it as well after I had got some confirmation that it is a bug ... :D
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Bug confirmed by Helios, "We'll fix it in the next maintenance release". I'm holding my breath here, so to all you professioal pearl divers out there, all advice accepted! ;)
Then I open up and see
the person fumbling here is me
a different way to be
rgduncan
Posts: 2
Joined: Mon Nov 28, 2005 1:35 am
Location: Seattle

Adding a header to a file

Post by rgduncan »

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
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

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

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
...
The replace regex would be something like except replace the newlines with \n and have this be a single string

Code: Select all

copy $1 $1.foo
echo My Cool String > $1
type $1.foo >> $1
del $1.foo
and then execute that batch script
I choose to fight with a sack of angry cats.
Post Reply