Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Exporting and naming individual text files
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1252585352

Message started by AsafKeller on Sep 10th, 2009, 8:22am

Title: Exporting and naming individual text files
Post by AsafKeller on Sep 10th, 2009, 8:22am

I would like to export notes as individual text files, and have these files automatically named as <date created>-<Name>. Is this possible?

Title: Re: Exporting and naming individual text files
Post by Johnnie Wilcox - mistersquid on Sep 10th, 2009, 11:43am

I think the only way to get this done is to add $Created to the $Name. You can do this with a Rule or Action that looks like


Code:
$Name = $Created +"delimiter"+$Name


where you replace the word delimiter (keeping the double quotes) with whatever you'd like to use to separate these two data. You can get fancier by formatting $Created with rule like


Code:
$Name=format($Created,"L")+" "+$Name


which in this example separates the two with a space.

===============

Thanks, everybody, for the clarifcations downthread.

Title: Re: Exporting and naming individual text files
Post by AsafKeller on Sep 10th, 2009, 12:04pm

Thanks, Johnnie. If I understand correctly, that will change the name of the Note, but not the name of the exported file, which defaults to "exported file".

Title: Re: Exporting and naming individual text files
Post by Mark Anderson on Sep 10th, 2009, 12:36pm

The exported filename is set via HTMLExportFilename. The export name is is auto-derived for the name (losing spaces and other non-URL safe characters) or as set otherwise either manually or via action code.  You could use Actions/Rule or perhaps a stamp to set this attribute to the value you want.

I see Mark B's already answered your parallel question about spaces in URLs and why they are generally deprecated.

Title: Re: Exporting and naming individual text files
Post by AsafKeller on Sep 10th, 2009, 12:45pm

Thanks, Mark. But this applies to html export, and not text export, correct? I was looking for a solution for exporting as text.
And any feedback on my question regarding export of individual text files (instead of the default behavior, where exported notes are coalesced into a single file)?

Title: Re: Exporting and naming individual text files
Post by Mark Bernstein on Sep 10th, 2009, 12:52pm

In fact, though it's called "HTML Export", there's no requirement that you export HTML.  For example, the template

      ^title
      ^text(plain)

will export the note's title, followed by a return, followed by its text.

Title: Re: Exporting and naming individual text files
Post by Mark Anderson on Sep 10th, 2009, 1:03pm

The term HTML Export is effectively a method for exporting marked-up text with HTML being the default mark-up. But you can as easily export text file.  If you're exporting via Nakakoji view, then I don't think there is a filename attribute - you supply it when you export. Nakakoji always exports a single file - with the contents depending on the scope of notes you select in the export pane.

If you want to export plain text files, i.e. '.txt', files that you'll need to set the HTMLExportExtension to 'txt'. also use templates that don't insert HTML. Don't take the 'HTML' part of HTML export too literally.

If none of this makes sense it might help if you explained, simply, for what purpose you want output.  By al means offer up a demo TBX of source and an a file simulating the output you want.  It's likely to be possible.

If sharing source data is too sensitive to post in the forum, by all means contact me (email button in my forum profile) so you can discuss the problem in a less public context. I'd only ask that if we get a solution, the generalities of the solution can be shared with fellow users (using made-up specimen data).

Title: Re: Exporting and naming individual text files
Post by AsafKeller on Sep 10th, 2009, 2:59pm

Got it; thanks Mark & Mark. Now all I need is for the spaces in exported file names to be retained, and I am all set! (http://bit.ly/2B3y08)

Title: Re: Exporting and naming individual text files
Post by Paul Walters on Sep 10th, 2009, 4:30pm

Try Automator.  If you export your files with a token where you want the space (e.g., ##) then you can make a workflow in Automator (with the Rename Finder Items action) that replaces the token ## with a space or whatever.  Save the workflow as a folder action attached to your output folder, and whatever is put there will automatically have the text replacement applied to it.

Title: Re: Exporting and naming individual text files
Post by Mark Anderson on Sep 10th, 2009, 5:33pm

Alternatively, you could use a command line script to process the file(s) in the output folder(s).  I've not tried this but HTMLExportCommand might do this. I'm not 100% sure if the command applies to the file contents or the file/contents. If the latter you could use a CL to substitute spaces for underscores exported folder (i.e. container) and file names. So whether trigger via TB or done in Terminal afterwards (or a CL called via Automator) there ought to be a fix.

I'm not sure how often this process is needed by users in general but perhaps it might be coped with by an HTML group attribute (false by default) that allows the user to suppress URL-encoding of folder/filenames.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.