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:

"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("created: " + timestamp + "000\n");
 //stream.write("modified: " + timestamp + "000\n");
 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/c570e246-ecb0-48b9-9d8c-7d82e87b758e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to