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');
let name = $(em).attr('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.