i connect with putty to my nas-server and run
(after logging in as root)
node /volume1/web/wiki/importexternal.js



Am Samstag, 20. August 2016 00:21:56 UTC+2 schrieb Mark S.:
>
> Impressive. How does this get invoked?
>
> On Friday, August 19, 2016 at 2:17:03 PM UTC-7, Dominik P. wrote:
>>
>> well i did a node js script workaround which
>>
>>    1. reads from a folder "import" all the files which should get 
>>    imported
>>    2. move the files to my external files folder "src"
>>    3. create .tid files which handle the visualisation per filetype
>>    4. also adds tags if i wish to
>>
>> not the best solution but saves me some time
>> here in case someone wants to use it:
>>
>> if anyone has ideas for improvement please let me know
>>
>> "importexternal.js"
>>
>> var tags = "";//tags for .tid files
>>
>> var fs = require( 'fs' );
>> var path = require( 'path' );
>> var process = require( "process" );
>>
>> var moveFrom = "/volume1/web/wiki/import";
>> var moveTo = "/volume1/web/wiki/tiddlers/src";
>> var tiddlersPath = "/volume1/web/wiki/tids2import/";//after i run the 
>> operation i'll drop those inside tw5 and delete em
>>
>> // Loop through all the files in the temp directory
>> fs.readdir( moveFrom, function( err, files ) {
>>         if( err ) {
>>             console.error( "Could not list the directory.", err );
>>             process.exit( 1 );
>>         } 
>>
>>         files.forEach( function( file, index ) {
>>                 // Make one pass and make the file complete
>>                 var fromPath = path.join( moveFrom, file );
>>                 var toPath = path.join( moveTo, file );
>> var title = path.basename(file);
>> title = title.replace(/\.[^/.]+$/, "");//remove .filetype
>>                 fs.stat( fromPath, function( error, stat ) {
>>                     if( error ) {
>>                         console.error( "Error stating file.", error );
>>                         return;
>>                     }
>>
>>                     if( stat.isFile() )
>>                         console.log( "'%s' is a file.", fromPath );
>>                     else if( stat.isDirectory() )
>>                         console.log( "'%s' is a directory.", fromPath );
>>
>>                     fs.rename( fromPath, toPath, function( error ) {
>>                         if( error ) {
>>                             console.error( "File moving error.", error );
>>                         }
>>                         else {
>>                             console.log( "Moved file '%s' to '%s'.", 
>> fromPath, toPath );
>> var stream = fs.createWriteStream(tiddlersPath + "/" + title + ".tid");
>> stream.once('open', function(fd) {
>>  stream.write("tags: " + tags + "\n");
>>  stream.write("title: " + title + "\n");
>>  stream.write("type: text/vnd.tiddlywiki\n\n");
>>  var filetyperesult = file.indexOf("mp3") > -1;
>>  if(filetyperesult){
>>   stream.write('<<mp3 "' + title + '">>');
>>  } filetyperesult = file.indexOf("mp4") > -1;
>>  if(filetyperesult){
>>   stream.write('<<mp4 "' + title + '">>');
>>  } filetyperesult = file.indexOf("pdf") > -1;
>>  if(filetyperesult){
>>   stream.write('<<pdf "' + title + '">>');
>>  }
>>  stream.end();
>> });
>> console.log( "created '%s'.tid", title );
>>                         }
>>                     } );
>>                 } );
>>         } );
>> } );
>>
>>  
>>
>> Am Donnerstag, 18. August 2016 22:20:28 UTC+2 schrieb Dominik P.:
>>>
>>> hello tw5 community
>>>
>>> i would like to drop files (mp3 mp4 jpg ..) inside tw5 
>>> and instead of importing them to save them to a subfolder and create a 
>>> tiddler with filename as title 
>>> and inserted (handlerchanged) content based on filetype (mp3 mp4 jpg 
>>> ..) associated templates (e.g. pdfs: content <iframe/> with filepath 
>>> inserted inside src="")
>>>
>>> any help appreciated
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5abb2965-6025-42d1-a08d-021f0ecbbede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to