[mythtv-users] WAaay OT: Just trying to pick the brains of anyone who can help ... Batch txt edit insert title

Another Sillyname anothersname at googlemail.com
Wed Jul 13 21:35:31 UTC 2011


On 13/07/2011, Richard Shaw <hobbes1069 at gmail.com> wrote:
> On Wed, Jul 13, 2011 at 3:59 PM, Damian <myth at surr.co.uk> wrote:
>> Hello all,
>>
>> This has NOTHING to do with MythTV as all and everything to do with the
>> fact that I've searched high and low for an answer to this problem,
>> failed to come up with anything and know that you lot are the most
>> knowlegeable group of computerists that I know.
>>
>> So, if anty of you are still reading ...
>>
>> Basically, I need to add the title of a text file to the first line of
>> the body of the same text file (followed by a couple of carridge returns
>> if possible). I then need to do this for about 400 hundreds of files!
>
> Have you tried?
>
> http://lmgtfy.com/?q=sed+insert+first+line
>
> Anyway, it doesn't give you the whole solution but it does give you
> the insert piece.
>
> I haven't tested this so consider it unstable meta code but something
> like...
> """
> #!/bin/bash
> for file in $1; do
>     sed -i '1i\$(basename $file ${file/*./}' $file
> done
> """
>
> Or something like that... the "${file/*./} is supposed to just give
> you the extension so basename knows to output the filename sans the
> extension but I've never done it that way before.
>
> Richard
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-users
>


Are all the files in the same directory?


More information about the mythtv-users mailing list