🔹 Why Automate with JavaScript?
• Cross-platform with Node.js
• Easily schedule with cron or npm packages
• Ideal for developers already using JS
• Replaces manual scripts and boosts productivity
10 Daily Tasks I Automate Using JavaScript
1. ✅ Auto-Clean Old Files from Downloads Folder
const fs = require('fs');
const path = require('path');
const folderPath = '/Users/yourname/Downloads';
const daysOld = 7;
const now = Date.now();
fs.readdir(folderPath, (err, files) => {
files.forEach(file => {
const filePath = path.join(folderPath, file);
fs.stat(filePath, (err, stats) => {
const diffTime = (now - stats.ctimeMs) / (1000 * 3600 * 24);
if (diffTime > daysOld) fs.unlinkSync(filePath);
});
});
});
Why: Frees space automatically, no more clutter.
2. 📧 Daily Email Reminder Using NodeMailer
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'youremail@gmail.com',
pass: 'yourpassword'
}
});
transporter.sendMail({
from: 'youremail@gmail.com',
to: 'receiver@example.com',
subject: 'Daily Reminder',
text: 'Don't forget to write your blog today'
})
Why: Keeps your goals top of mind, daily.
3. 🔎 Check Website Uptime with Axios
const axios = require('axios');
axios.get('https://techquestworld.com')
.then(res => console.log('Website is UP'))
.catch(err => console.log('Website is DOWN'));
Why: Uptime monitoring = peace of mind.
4. 📅 Auto-Google Calendar Reminder (with Google API)
a. Install Required Packages
npm install googleapis dotenv
b. Create .env File
GOOGLE_CLIENT_ID=your_client_id
GOOGLE_CLIENT_SECRET=your_client_secret
GOOGLE_REDIRECT_URI=https:
GOOGLE_REFRESH_TOKEN=your_refresh_token
You can get these credentials from Google Cloud Console and use OAuth 2.0 Playground to generate the refresh token.
c. Create calendar.js File
require('dotenv').config();
const { google } = require('googleapis');
const oAuth2Client = new google.auth.OAuth2(
process.env.GOOGLE_CLIENT_ID,
process.env.GOOGLE_CLIENT_SECRET,
process.env.GOOGLE_REDIRECT_URI
);
oAuth2Client.setCredentials({ refresh_token: process.env.GOOGLE_REFRESH_TOKEN });
const calendar = google.calendar({ version: 'v3', auth: oAuth2Client });
const event = {
summary: 'Morning Reminder: Check Emails & Plan Tasks',
location: 'Your Desk',
description: 'Automated daily reminder using Google Calendar API',
start: {
dateTime: '2025-05-27T06:00:00+05:30',
timeZone: 'Asia/Kolkata',
},
end: {
dateTime: '2025-05-27T06:30:00+05:30',
timeZone: 'Asia/Kolkata',
},
reminders: {
useDefault: false,
overrides: [
{ method: 'popup', minutes: 10 },
],
},
};
calendar.events.insert(
{
calendarId: 'primary',
resource: event,
},
(err, res) => {
if (err) {
console.error('Error creating event:', err);
return;
}
console.log('✅ Event created successfully:', res.data.htmlLink);
}
);
Why: Never miss a meeting again.
5. 🧹 Clear Cache and Temp Files
const tempPath = '/Users/yourname/temp';
Why: Keeps your system fast.
6. 📂 Auto-Sort Files by Type Using Node.js
a. Setup Project
mkdir auto-file-sorter
cd auto-file-sorter
npm init -y
npm install fs path
b. sortFiles.js
const fs = require("fs");
const path = require("path");
const folderPath = path.join(__dirname, "downloads");
const fileTypes = {
images: [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp"],
videos: [".mp4", ".avi", ".mov", ".mkv", ".webm"],
documents: [".pdf", ".docx", ".doc", ".xlsx", ".pptx", ".txt"],
music: [".mp3", ".wav", ".aac", ".flac"],
archives: [".zip", ".rar", ".7z", ".tar", ".gz"],
code: [".js", ".html", ".css", ".py", ".php", ".java", ".c", ".cpp", ".ts"]
};
const ensureFolder = (folderName) => {
const folder = path.join(folderPath, folderName);
if (!fs.existsSync(folder)) fs.mkdirSync(folder);
return folder;
};
const sortFiles = () => {
fs.readdir(folderPath, (err, files) => {
if (err) return console.log("❌ Error reading folder:", err);
files.forEach(file => {
const ext = path.extname(file).toLowerCase();
const fromPath = path.join(folderPath, file);
if (fs.lstatSync(fromPath).isDirectory()) return;
let moved = false;
for (const [type, extensions] of Object.entries(fileTypes)) {
if (extensions.includes(ext)) {
const toFolder = ensureFolder(type);
const toPath = path.join(toFolder, file);
fs.renameSync(fromPath, toPath);
console.log(`✅ Moved ${file} → ${type}/`);
moved = true;
break;
}
}
if (!moved) {
const othersFolder = ensureFolder("others");
fs.renameSync(fromPath, path.join(othersFolder, file));
console.log(`📦 Moved ${file} → others/`);
}
});
});
};
sortFiles();
Run:
Why: Keeps your workspace organized.
7. 🧾 Daily Expense Logger with File Write
const fs = require('fs');
fs.appendFileSync('expenses.txt', `Food: $10 - ${new Date().toLocaleDateString()}\n`);
Why: Quick logging helps track your budget.
8. 🎵 Auto-Play YouTube Playlist at 6 AM (with Puppeteer)
a. Install Required Packages
npm install puppeteer node-schedule
youtubePlaylistAutoPlayer.js
const puppeteer = require('puppeteer');
const schedule = require('node-schedule');
const playlistURL = 'https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID';
async function autoPlayPlaylist() {
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
args: ['--start-maximized']
});
const page = await browser.newPage();
await page.goto(playlistURL, { waitUntil: 'networkidle2' });
try {
await page.click('button[aria-label="Accept all"]', { timeout: 3000 });
} catch (e) {
}
try {
await page.waitForSelector('ytd-playlist-video-renderer', { timeout: 5000 });
console.log('Playlist loaded. Autoplay will begin.');
} catch (err) {
console.log('Could not find playlist or play button.');
}
}
schedule.scheduleJob('0 6 * * *', () => {
console.log('⏰ Launching YouTube Playlist at 6 AM...');
autoPlayPlaylist();
});
autoPlayPlaylist();
Why: Start your day with a boost.
9. 📈 Fetch Stock Prices (or Crypto Rates)
axios.get('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd')
.then(res => console.log(`BTC: $${res.data.bitcoin.usd}`));
Why: Daily investment check-in made easy.
10. 🔔 Desktop Notification for Break Reminder
const notifier = require('node-notifier');
notifier.notify('Time to stretch and rest your eyes');
Why: Prevent burnout and fatigue.
Bonus: Automate with Cron
Use node-cron to schedule these scripts daily:
const cron = require('node-cron');
cron.schedule('0 8 * * *', () => {
console.log('Running daily automation...');
});
Try one script today. Comment below which task you'll automate first. Subscribe to TechQuestWorld for weekly developer hacks.