JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Project: File Organizer (Simplified Version) | JustPaste.app
10 days ago3 views
👨‍💻Programming

Project: File Organizer (Simplified Version)

Practicing: os module, loops, conditionals

The Scenario

Your Downloads folder is a mess — photos, PDFs, videos all mixed together. You're going to build a program that sorts files into subfolders automatically.

No typing paths, no separate test folder — your program will just organize whatever's sitting in the same folder as your script itself.

Setup — do this first

  1. In the same folder where you'll save your Python script, add a few empty dummy files:

   photo1.jpg
   photo2.png
   report.pdf
   notes.txt

(Empty files are fine — you don't need real content, just the right names and extensions.)

Your folder should look like this before running anything:

your_project_folder/
    your_script.py
    photo1.jpg
    photo2.png
    report.pdf
    notes.txt

Step-by-Step Instructions

Build your program to do the following, in this order.

Step 1 — Import what you need

You'll need two modules: one that can list files and create folders, and one that can actually move files from one place to another.

Step 2 — Set the folder to organize

Instead of asking the user, just set a variable equal to "." — this special value means "the folder this script is currently sitting in."

Step 3 — Create two subfolders

Your program should create two new subfolders inside the current folder: Images and Documents. Look for a function that creates a folder — and find the extra option that tells it "don't complain if it already exists," so running your program more than once doesn't cause an error.

Step 4 — Get the list of files

Get a list of everything currently in the folder. Store it in a variable.

Step 5 — Set up two counters

Create two variables, both starting at 0, to count how many images and how many documents get sorted.

Step 6 — Loop through every item in the folder

For each item you find:

  • Skip it if it's named "Images" or "Documents" (your own subfolders).

  • Skip it if its name ends in .py (that's your script itself — don't sort your own code!).

Hint: you can check multiple conditions with or inside one if statement.

Step 7 — Check the file type and decide where it goes

For everything that wasn't skipped:

  • If the filename ends with .jpg or .png → it belongs in Images

  • If the filename ends with .pdf or .txt → it belongs in Documents

  • Anything else → skip it for now, we're not handling other types yet

Use if / elif / else for this, same pattern as your bill calculator project.

Step 8 — Build the destination and move the file

Once you know which category a file belongs to, you need to combine the folder name + category name + filename into one destination path, then actually move the file there. Look for the function that "joins" path pieces together, and the function that "moves" a file.

Also increase the matching counter by 1 each time you sort a file.

Step 9 — Print confirmation as you go

Each time a file gets moved, print a line confirming it, like: Moved: photo1.jpg

Step 10 — Print your final counts

After the loop finishes, print how many images and how many documents were sorted in total.

Expected Output

If your program works correctly, running it should print:

Moved: photo1.jpg
Moved: photo2.png
Moved: report.pdf
Moved: notes.txt
Images moved: 2
Documents moved: 2

And when you check your project folder afterward, you should see two new subfolders — Images and Documents — with your dummy files inside them instead of loose in the main folder.

Questions to Answer (write your answers as comments at the top of your file)

  1. What does "." mean when used as a folder path?

  2. Why do we skip the file if it ends with .py?

  3. What happens if you run the program a SECOND time right after the first? Try it and explain why that happens.

Stretch Goal (only if you finish early)

Add a third category for videos (.mp4) — one more elif, one more counter, same pattern as Images and Documents.

Coming Later

Once this version works, we'll add back the part where the program asks you for a folder path instead of always using the folder it's sitting in.

Submission

Save as LastName_FirstName_FileOrganizer.py and submit via the usual link.

← Back to timeline