title: Node js remove old files in a Directory
body: <p>I want to remove some files in a directory after reaching some limits.(for example remove files if number of files more than 20)</p>
  
  <p>It would be great if any automation can be done to remove those files.</p>
  
  <p><strong>In details:</strong>
  In my case there is a uploads directory, where I'm uploading the images. For each new image, a directory is created and the image resides in the directory. So I want to keep some of the newly created or recently used directories and remove others after a certain limit(for example after reaching 20 numbers of directories). While creating new images, it'll check the limit and if exceeds the max dir limits, it'll remove the unused directories. </p>
  
  <p>Note: The directories are not empty.</p>
  
  <p>How can i do that using Node.js</p>
  
  <p>Any help would be appreciable.</p>