okido,

That's good to hear. I'll be anxiously following your progress.

David

On Aug 4, 7:09 pm, okido <[email protected]> wrote:
> Hi Kanyimbe,
>
> I am working on a plugin that can generate tiddlers with the filenames
> from files in a directory.
> A list is made of tiddlers that exist's but the file is missing.
> It is partly based on the code from Eric Schulman's 
> pluginhttp://www.tiddlytools.com/#ShowLocalDirectory.
> It is not a working plugin yet but you might try the code below by
> simply pasting it in a tiddler, you need the inlinejavascript plugin
> from Tiddlytools and be aware of google line breaks.
> Opening and closing the tiddler starts the process, be CAREFUL there
> are no safeguards build in, make sure you have a backup in case
> something goes wrong.
> The docs are expected to be in a sub-directory with the name docs.
> Reading the metadata from files is something that I have been thinking
> of and this should be possible from TW but it takes some major coding.
>
> Goodluck, Okido
>
> <script>
> {
> // store.deleteTiddler('test.pdf');
> // store.deleteTiddler('test_1.pdf');
> var out = [];
> var tagslist = 'newdocs docs'; // tags that are added to tiddler
> var path = 'docs'; // directory name
> var user_name = 'Yourname';
> var tot = 0;
>
>           window.getCurrentFolder=function() {
>           var h=document.location.href;
>            return
> getLocalPath(decodeURIComponent(h.substr(0,h.lastIndexOf("/")+1)));
>         }
>
>                 window.getParentFolder=function(cwd) {
>                 var lastchar=cwd.substr(cwd.length-1,1);
>                 if (lastchar=="/" || lastchar=="\\") 
> cwd=cwd.substr(0,cwd.length-1);
>                 var pos=cwd.lastIndexOf("/"); if (pos==-1) 
> pos=cwd.lastIndexOf("\
> \");
>                 return pos!=-1?cwd.substr(0,pos+1):null;
>         }
>
>         window.getFileList=function(cwd) { // returns array of file info
> (path,name,size,isFolder,url,modified)
>                 var files=[];
>                 if (config.browser.isIE) {
>                         cwd=cwd.replace(/\//g,"\\");
>                         var fso = new 
> ActiveXObject("Scripting.FileSystemObject");
>                         if(!fso.FolderExists(cwd)) return [];
>                         var dir=fso.GetFolder(cwd);
>                         for(var f=new Enumerator(dir.SubFolders); !f.atEnd(); 
> f.moveNext())
>                                 files.push({ path:f.item().path, 
> name:f.item().name,
> size:f.item().size,
>                                         
> url:"file:///"+f.item().path.replace(/\\/g,"/"),
> isFolder:fso.FolderExists(f.item().path),
>                                         modified:new 
> Date(f.item().DateLastModified).formatString("YYYY.
> 0MM.0DD 0hh:0mm:0ss")});
>                         for(var f=new Enumerator(dir.Files); !f.atEnd(); 
> f.moveNext())
>                                 files.push({ path:f.item().path, 
> name:f.item().name,
> size:f.item().size,
>                                         
> url:"file:///"+f.item().path.replace(/\\/g,"/"),
> isFolder:fso.FolderExists(f.item().path),
>                                         modified:new 
> Date(f.item().DateLastModified).formatString("YYYY.
> 0MM.0DD 0hh:0mm:0ss")});
>                 } else { // FF
>                         if(!window.Components) return;
>                         try
> { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
>                         catch(e) { 
> alert(e.description?e.description:e.toString()); return
> null; }
>                         var file=Components.classes["@mozilla.org/file/local;
> 1"].createInstance(Components.interfaces.nsILocalFile);
>                         try { file.initWithPath(cwd); } catch(e) { return []; 
> }
>                         if (!file.exists() || !file.isDirectory()) { return 
> []; }
>                         var folder=file.directoryEntries;
>                         while (folder.hasMoreElements()) {
>                                 var
> f=folder.getNext().QueryInterface(Components.interfaces.nsILocalFile);
>                                 if (f instanceof 
> Components.interfaces.nsILocalFile)
>                                         files.push({path:f.path, 
> name:f.leafName, size:f.fileSize,
>                                                 isFolder:f.isDirectory(), 
> url:"file:///"+f.path.replace(/\\/
> g,"/"),
>                                                 modified:new 
> Date(f.lastModifiedTime).formatString("YYYY.0MM.0DD
> 0hh:0mm:0ss")});
>                         }
>                 }
>                 return files;
>         }
>
>     listresults = function() {
>     out.push('!Linker Report');
>     out.push('Path used: ' + cwd );
>     out.push('Number of files in path: '  + files.length);
>     out.push('Tag added: ' + tagslist );
>     out.push('Username: ' + user_name );
>     out.push('!!Added tiddlers');
>
> }
>
>       date_conv = function(date) {    // convert file date to TW date
> format
>        date = date.replace(' ','.');
>        date = date.split('.');
>        return new Date(date[0],date[1]-1,date[2]); // date of creation
>
> }
>
>       write_tiddler = function(title,date) {
>             out.push(tot++ + ' ' + '[[' + title + ']]' );
>             var newTitle = line[1]; // tiddler title
>             var newBody = '[[' + title + '|docs/' + title + ']]';  //
> text in the tiddler
>             var dt = date_conv(date); // convert date toTW formaat
>             var newTags = tagslist; // ' newdocs docs'
>             store.saveTiddler(newTitle, newTitle, newBody, user_name,
> dt, newTags);
>                // displayMessage('New document tiddlers created');
>                // story.displayTiddler('top',newTitle);
>                 saveChanges();
>  }
>
>       missing_file = function(title) {
>       out.push('file missing');
>       }
>
>   // Main loop
>     var cwd = getCurrentFolder() + path ; //sub folder were the docs
> are located
>     var files = getFileList(cwd);
>     listresults(); // print the results of loading files
>
>        var line=[];     // check if the tiddler exists and write if
> not
>          for (var i=0; i<files.length; i++) {
>          var
> line=([files[i].path,files[i].name,files[i].url,files[i].size,files[i].modified]);
>          var tid = store.tiddlerExists(line[1])?"Y":
> write_tiddler(files[i].name,files[i].modified);
>          }
>
>  exist_file = function(title) {
>    exist = 'false';
>    for( y = 0 ; y < files.length ; y++ ) {
>      if ( files[y].name == title ) {
>       exist = 'true';
>      }
>     }
>  return exist;
>  }
>
> // non exsisting files
>    out.push('!!Tiddlers tagged but no file');
>     var tids=store.getTaggedTiddlers('docs');
>      for( i = 0 ; i < tids.length ; i++ ) {
>       if ( exist_file(tids[i].title) == 'false') {
>        out.push('[['+ tids[i].title + ']]');
>     }
>
> }
>
> return out.join('\n');}
>
> </script>
>
> On 4 Aug, 08:45, Kanyimbe <[email protected]> wrote:
>
> > Thanks for that. I'm also looking at 
> > libextractorhttp://www.gnu.org/software/libextractor/
>
> > On Jul 29, 6:50 am, PMario <[email protected]> wrote:
>
> > > hi,
> > > exiftool may be of interest.
>
> > >http://www.sno.phy.queensu.ca/~phil/exiftool/
>
> > > -m

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to