[mythtv-users] WAaay OT: Just trying to pick the brains of anyone who can help ... Batch txt edit insert title
Ian Clark
mrrooster at gmail.com
Fri Jul 15 13:36:58 UTC 2011
On 13 July 2011 21:59, 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!
>
> The reason is that I have had all of my reference notes from all
> projects/thoughts/notes etc in a system called Rightnote (which took
> over from Keynote). I'm now wanting to import all of these files into
> Evernote.
>
> I can export from Right note fine, as either text, rich text or html and
> I can tell Evernote to import all of the files put into X folder.
>
> Unfortunately, Evernote only imports the body of the text files and
> ignores the titles. It gives the notes a title based on the first line
> of the body of text.
>
> I have tried speaking to Evernote, but they say that their import system
> is like that deliberately. The only way around it I can think of is to
> make the first line of the contents of each text file the same as the
> title of that text file.
>
> Unfortunately, I've searched high and low and can not find a way to do this.
>
> Can any of you help?
>
To add the filename as the first line of the file for all files in /foo:
backup first:
tar -czf /some/tar/file.tgz -C /foo .
(I always tar -tzf /some/tar/file.tgz to check it looks right too. :) )
for thing in `find /foo -type f`;do echo Processing:
$thing;tmp=`mktemp -t blabla`;echo $thing > $tmp;cat $thing >> $tmp;mv
$tmp $thing;done
Find all files in /foo.
Echo 'processin <filename>'
Create a tempory file to work with
echo the filename to the first line of the temp file. (This is the bit
to change if you want somethine else)
append the file to the temp file
move the temp file over the orig file.
If you want to put something else as the first line then the 'echo
$thing' bit should be changed.
eg:
echo "This is a title" > $tmp
HTH,
Cheers,
Ian
More information about the mythtv-users
mailing list