import files to subfolder

171 views
Skip to first unread message

Dominik P.

unread,
Aug 18, 2016, 4:20:28 PM8/18/16
to tiddl...@googlegroups.com
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

PMario

unread,
Aug 19, 2016, 6:03:35 AM8/19/16
to TiddlyWiki
Hi Dominik,

You'll need to use the _canonical_uri field. see: http://tiddlywiki.com/#Blurry%20Lawn.jpg:%5B%5BBlurry%20Lawn.jpg%5D%5D%20ImageWidget%20Audio%20%5B%5BCaruso%20-%20Ave%20Maria%5D%5D 
Open the image and audio tiddlers, to see them in edit mode.

have fun!
mario

Dominik P.

unread,
Aug 19, 2016, 8:11:36 AM8/19/16
to TiddlyWiki
thank you, is there a way to do that automatically with import drop (for every file except .json, .tid for example) that is then moved to external folder?

PMario

unread,
Aug 19, 2016, 11:06:02 AM8/19/16
to TiddlyWiki
On Friday, August 19, 2016 at 2:11:36 PM UTC+2, Dominik P. wrote:
thank you, is there a way to do that automatically with import drop (for every file except .json, .tid for example) that is then moved to external folder?

I don't think so. ... but it probably should :)
-m

Jeremy Ruston

unread,
Aug 19, 2016, 11:53:15 AM8/19/16
to tiddl...@googlegroups.com
Hi Dominik

thank you, is there a way to do that automatically with import drop (for every file except .json, .tid for example) that is then moved to external folder?

I don't think so. ... but it probably should :)

For security reasons, browsers make it impossible for TiddlyWiki to save external files. That means that there’s no way to do this with the standalone, single file configuration of TiddlyWiki.

Best wishes

Jeremy.


-m

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
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/5cffd3bd-f197-43a0-ad7e-1f571ae360d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dominik P.

unread,
Aug 19, 2016, 12:12:48 PM8/19/16
to TiddlyWiki
thanks jeremy, same goes for the node js server version?

Mark S.

unread,
Aug 19, 2016, 12:57:35 PM8/19/16
to TiddlyWiki
There is another work-around that you can experiment with. Although you can't drag and drop from outside the browser, you can drag and drop from *inside* the browser using tiddlyclip (http://tiddlyclip.tiddlyspot.com/) and local mode. You set up your tiddlyclips and then dock to your TW and select "localsnips" mode. Then you navigate to your files inside a nearby file tab. When you find the file you want, you right click, select the Tiddlyclip with localsnips option, and then the image type. You can find the image back in your TW file under "Recent".

Just tried it to verify that this method works. The only problem is that it doesn't generate relative links, so I would need to go back in and fix them up if I want the result to be portable. I seem to recall that there's some way to make it use relative links, but don't remember what that is.

Maybe someday someone will develop a FF plugin that will allow TW to become a true Evernote replacement.

Good luck!

Danielo Rodríguez

unread,
Aug 19, 2016, 2:40:39 PM8/19/16
to TiddlyWiki
Hello Mark

>>Maybe someday someone will develop a FF plugin that will allow TW to become a true Evernote replacement.

What are you missing exactly to consider TW as a full Evernote replacement?

Dominik P.

unread,
Aug 19, 2016, 5:17:03 PM8/19/16
to tiddl...@googlegroups.com
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 );
                        }
                    } );
                } );
        } );
} );

 

Mark S.

unread,
Aug 19, 2016, 6:21:56 PM8/19/16
to TiddlyWiki
Impressive. How does this get invoked?

Dominik P.

unread,
Aug 19, 2016, 6:31:11 PM8/19/16
to TiddlyWiki
i connect with putty to my nas-server and run
(after logging in as root)
node /volume1/web/wiki/importexternal.js


Mark S.

unread,
Aug 19, 2016, 6:35:42 PM8/19/16
to TiddlyWiki
Pretty much like in the OP. Drag and drop a file from *anywhere* into TW, and have the file stored in a subdirectory while simultaneously creating a tiddler in the TW file. Right now, even with tiddlyclip, there are too many steps.

The other thing, for the long term, is that there needs to be a true TW app. Using FF or AndTidWiki requires about 20 seconds for the page to come up. And the page will automatically disappear at times when you visit other apps. I assume this is because the TW page takes up too much memory.

The other thing, is that there is no way that I know of to "share" an image or article with TW the way you can with Evernote.

One of the best open-source information managers I've seen for Android is Tom-Boy. The interface is really nice, and behind the scenes it uses files that are not unlike .tid files. I'm wondering if it could be re-engineered to become an app interface for TW.

Thanks!
Mark

Dominik P.

unread,
Aug 19, 2016, 6:40:31 PM8/19/16
to tiddl...@googlegroups.com
ye if you could drop stuff on an opened tiddler which inherits its title as tag to the imported files would be awesome

i thought i could use subfolders inside my import folder to act as giving tags - but too much hassle atm

my solution fits my needs so far - if anyone could do the same with standalone version even on androids would be awsm
Reply all
Reply to author
Forward
0 new messages