Skip to content

Instantly share code, notes, and snippets.

@Cykelero
Created August 20, 2019 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cykelero/d5ae98ddeff5b9fb958acd00112253d2 to your computer and use it in GitHub Desktop.
Save Cykelero/d5ae98ddeff5b9fb958acd00112253d2 to your computer and use it in GitHub Desktop.
A very simple script: written in Tasklemon, and written with the built-in Node.js APIs
// Tasklemon
home.children.forEach(child => {
if (child.extension === 'tmp') child.delete();
});
// Node.js
const fs = require('fs');
const os = require('os');
const path = require('path');
const folderPath = os.homedir();
fs.readdirSync(folderPath).forEach(childName => {
if (path.parse(childName).ext === '.tmp') {
const absolutePath = path.join(folderPath, childName);
fs.unlinkSync(absolutePath);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment