Page 1 of 1
Adding a header to files
Posted: Thu Mar 17, 2005 4:34 am
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!
Posted: Thu Mar 17, 2005 5:59 am
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
Hope it helps.
Posted: Thu Mar 17, 2005 10:04 am
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
Posted: Thu Mar 17, 2005 8:18 pm
by s_reynisson
Same results here, posted a bug report from the support page. Thx for the pointer.
Posted: Thu Mar 17, 2005 8:52 pm
by MudGuard
I was going to report it as well after I had got some confirmation that it is a bug ...
Posted: Fri Mar 18, 2005 5:26 pm
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!
Adding a header to a file
Posted: Mon Nov 28, 2005 1:38 am
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
Posted: Mon Nov 28, 2005 3:38 pm
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