Skip to content

Recursively scan the contents of a folder based on certain file types.

Notifications You must be signed in to change notification settings

jbradleybriggs/FolderScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

FolderScanner

Scan the contents of a folder, filtering on certain file types. The scan can be done both asynchronously and synchronously; the asynchronous version is recommended since recursively reading the contents of a folder and all its sub folders etc. can cause a major code block if done synchronously.

Installation

Install the module with: npm install @drama_llama/folderscanner --save

Useage

  const FolderScanner = require('FolderScanner');
  var fscan = new FolderScanner() ;
  
  // Asynchronously scan the downloads folder for JPEG and PNG files:
  fscan.scan("/home/username/Downloads", ['.jpg', 'jpeg', '.png'])
       .then((list) => {
          // do something with list
          console.log(list) ; 
        }) ;
  
  // Synchronously scan Program Files for EXE files:
  var list = fscan.scanSync("C:\\Program Files", ['.exe']) ;
  // do something with the list
  console.log(list) ;
  
  //Asynchronously scan for all file types in the Downloads folder but without recursing:
  fscan.scan("/home/username/Downloads", [], false)
       .then((list) => {
          //do something with list
          console.log(list) ; 
        }) ;

About

Recursively scan the contents of a folder based on certain file types.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published