file-query.js – nodejs module using jQuery to manipulate your folders/files

Recently, I wrote a opensource node.js module “file-query” and put on github. (It is my first opensource github project.)

The basic concept of this module is mapping folder directory structure into virtual DOM structure. And then the module allow you to use jQuery syntax to select and even manipulate the virtual DOM structure in order to manipulate folders/files.




var fileQuerySync = require('file-query').fileQuerySync;

var $ = fileQuerySync('D:/root/d1');

$(`dir[filepath="D:/root/d1/d2"] dir[name=d3]`)
  .each(function(i, em){
    let name = $(em).attr('name');
    $(em).renameSync('renamed '+name);

The above code first load the “file-query” module, and then scan folder structure’D:/root/d1′ in order to create virtual DOM mapping.

And then in the later code, we use jQuery selector and manipulation functions just like what we do usually with jQuery. We find directories under path “d:/root/d1/d2”. And then find directory “d3”. And then find all directories under it which has name start with “abc”. And then find all child files. Finally we rename all those files.

More examples can be found in the Github webpage.


Leave a Reply

Your email address will not be published.