n
16

PSA: My first Python script to sort my music files did something wild

I was messing around with the os and shutil modules last night, trying to write a simple script that would move my mp3 files into folders by artist. I had about 300 songs in one messy folder. I ran the script and it worked, but then I saw my pictures folder was empty. I panicked for a solid minute before I realized my code had a bug. I used a wildcard that grabbed all files, not just .mp3, and moved everything into new folders based on weird parts of the filenames. I spent an hour fixing it by adding a check for file extensions. I learned that small mistakes in your code can have big, weird results. Has anyone else had a script do something totally unexpected like that?
3 comments

Log in to join the discussion

Log In
3 Comments
mila_king22
Sounds like you just organized your whole computer by accident lol. At least you got your files back, could've been way worse.
7
logan_owens14
Tell me about it, I've done that exact thing before. The panic is real when everything just disappears. You find anything cool you forgot you had?
7
verafoster
verafoster23d ago
My friend's script once renamed every file on his desktop to "temp" plus a number.
-1