Re: [Zim-wiki] How to use txt2tags across folders?
On Tue, May 5, 2009 at 22:16, Jaap Karssenberg wrote: > untested example script: > > #!/usr/bin/python > import sys > dir = sys.argv[1] > for root, dirs, files: # The above line should be: for root, dirs, files in os.walk(dir): > for file in files: > if file.endswith(".t2t"): > fh = open(root+'/'+file) > for i in range(4): > fh.readline() # skip 4 lines of headers > for line in fh: > sys.stdout.write(line) > # Mixing readline and "for line in fh" is AFAIK not recommended # because of internal buffering issues. More reliable: flines = iter(open(root+'/'+file)) for i in range(4): flines.next() # skip 4 lines of headers for line in flines: sys.stdout.write(line) # Or better yet (doesn't assume 4 lines): flines = iter(open(root+'/'+file)) for line if flines: # skip headers if line.strip() == "": break for line in flines: sys.stdout.write(line) > This script would write all content to the terminal, so you can redirect it > into a single file. > -- Beni ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] How to use txt2tags across folders?
Svenn Are Bjerkem wrote: Obviously I don't know how to run txt2tags on a hierarchy of t2t files, and I have not been able to find any option to do so. Maybe I am missing something, but I am very new to txt2tags. No clue either whether t2t has support for this. I added the export to t2t on a user request, but never really used it myself. That said it seems to me you might need a small script that concatenates the files to a single t2t file, which in turn can be converted to t2t. Of course zim should have an export option to export to a single file directly as well as native latex support - but those features are still on the wish list ... Regards, Jaap untested example script: #!/usr/bin/python import sys dir = sys.argv[1] for root, dirs, files: for file in files: if file.endswith(".t2t"): fh = open(root+'/'+file) for i in range(4): fh.readline() # skip 4 lines of headers for line in fh: sys.stdout.write(line) This script would write all content to the terminal, so you can redirect it into a single file. ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp