Lazo Lab Sign up

Python Projects & Skills / The web and automation

Lesson 23 of 28

Automating boring tasks

Python can rename hundreds of files, sort downloads into folders, or send you a daily report. If you do it more than three times, script it.

Key points

  • shutil.move moves files
  • schedule or cron runs scripts on a timer
  • Test on copies first
from pathlib import Path
import shutil
for f in Path("Downloads").glob("*.pdf"):
    shutil.move(str(f), "Documents/PDFs")
Watch a video on thisOpens YouTube search results for “Automating boring tasks” in a new tab

Quiz · +10 XP

What should you do before running a script that moves lots of files?

Log in to save progress and earn XP.